Rails - Using %W

后端 未结 4 782
借酒劲吻你
借酒劲吻你 2021-02-06 21:43

I have the following which works well:

def steps
    %w[hello billing confirmation]
end

steps.first

But I want to do this:

  d         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 22:31

    %w() is a "word array" - the elements are delimited by spaces.

    There are other % things:

    %r() is another way to write a regular expression.

    %q() is another way to write a single-quoted string (and can be multi-line, which is useful)

    %Q() gives a double-quoted string

    %x() is a shell command.

提交回复
热议问题