From: "David A. Black" Date: 2009-02-26T21:56:23+09:00 Subject: Re: Where is splat implemented? / How does it work? Hi -- Mischa Fierer wrote: > Thanks for all the replies. > > I've taken a lot of the stuff here, plus all the examples I could find > for the splat, and written what I think is probably the most definitive > guide at this point. You can run it yourself, as well, which should be > useful. > > Some of the examples are from a post David Black made a year or so ago, > others are from Rick and matz. > > http://github.com/mischa/splat/tree/master > > I've also written it so that you can try to guess what the return value > will be. > > Please do let me know if anything is wrong with it, also feel free to > fork and add your own examples / tests. Note this change, between 1.8 and 1.9: 1.8: >> *a = [1,2,3] => [[1, 2, 3]] >> a => [[1, 2, 3]] 1.9: >> *a = [1,2,3] => [1, 2, 3] >> a => [1, 2, 3] I think this means that my "that which, when wrapped in an array" formula doesn't work for this case any more -- though that formula was my best shot at a pithy way of describing the star, and may be outdated and/or incomplete in other ways. (I can't think of any, but someone else might :-) That's why I've always called this the "unary unarray" operator. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) Ruby Training Atlanta! April 1-3, http://www.entp.com/training/atlanta09