Check out example codes for "Ruby exclude from slice". It will help you in understanding the concepts better.

Code Example 1

# First of all you have to use splat (*) operator. 
# Then instead of using .slice() and .except() together, you can do this is more efficient way.

columns_to_show = ['age', 'gender', 'cast', 'fee_status']
columns_to_show = columns_to_show - hidden_columns if hidden_columns


patient.slice('age', 'gender', 'cast', 'fee_status').except(*hidden_columns)
 => {"cast"=>"black", "fee_status"=>"paid"}

Learn ReactJs, React Native from