I know how to do this:
%w(doc ppt xls).include?(fileext)
I now need something similar but the match terms have spaces in them. I've tried
%w("blah blah" "开发者_运维问答yada yada" "wowowow").include?(actiontype)
Goal here is to see if actiontype exists inside one of the quotes or not. Ideas?
Thanks
["blah blah", "yada yada", "wowowow"].include?(actiontype)
Or, you could choose to escape spaces.
%w(blah\ blah yada\ yada wowowow).include?(actiontype)
This second example really only makes sense when you rarely have a space, like:
%w(yellow red blue orange green black dark\ blue purple).include?(color)
["blah blah", "yada yada", "wowowow"].include?(actiontype)
If you're looking for an exact match, just use an array.
["blah blah", "yada yada", "wowowow"].include?(actiontype)
If it's something else that you're looking for, please ask a more specific question and include an example input and desired output.
精彩评论