So the standard way to write this seems to be array.include?(object)
. However I find that much harder to read and understand quickly compared to object.in(array). Is there anything like this in ruby?
The example I just hit this again was (user_role is a string, and allowed_user_roles is an array of strings):
allowed_user_roles.include?(user_role)
I know its probably personal preference, but I find this so much easier to read and comprehend.
user_role.in(allowed_user_roles)