Principle Of List Surprise #
Two array-related behaviors that took me off-guard this week.
Zsban Ambrus displayed this technique for ignoring a list assignment.
>> x, (*), z = [:x, :y, :z] => [:x, :y, :z] >> x => :x >> z => :z
And Christian Neukirchen showed the spooky split that the array constructor function does.
>> Array("foo\nbar") => ["foo\n", "bar"] >> $/ = ' '; Array( "i'm in your house" ) => ["i'm ", "in ", "your ", "house"]
retnuH
why
That looks right. If you want to capture all remaining array elements, use an asterisk on the
z
variable:Comments are closed for this entry.