๐ŸŒฟ What?

  • ๐ŸŒฑ %w return an splited array from a input string by space.
irb> %w(I am from Vietnam)
#=> ["i", "am", "from", "Vietnam"]
  • ๐ŸŒฑ %W is similar %w but allows receive interpolation value.
irb> country = "Vietnam" 
irb> %w(I am from #{country})
#=> ["i", "am", "from", "\#{country}"]
 
irb> %W(I am from #{country})
#=> ["i", "am", "from", "Vietnam"]
  • ๐ŸŒฑ Similar with %q, %Q, %i, %I, โ€ฆ

๐ŸŒฟ Refer