What is the origin of the notation "% i"?
Ruby classically supports the following literals:
%q[quack quack] #=> "quack quack" %r[quack quack] #=> /quack quack/ %w[quack quack] #=> ["quack", "quack"] %x[echo quack quack] #=> "quack quack\n" My understanding of the origin of this data is as follows:
%q[]for q uotes%r[]for r egex%w[]for w ords%x[]for e x ecute
Ruby 2.0 introduced the notation %i :
%i[quack quack] #=> [:quack, :quack] Why i ?
+4
1 answer
This is probably a reference to the String#intern method used to get a character from a string.
"foo".intern #=> :foo +9