From: Pete Higgins Date: 2011-12-09T02:33:52+09:00 Subject: Re: Confusing results from string multiplication --bcaec501c5dc56428904b39812ee Content-Type: text/plain; charset=ISO-8859-1 On Thu, Dec 8, 2011 at 9:09 AM, Rob Marshall wrote: > Hi Robert, > > Well, for someone who is new to Ruby, how would I, or anyone for that > matter, know that doing: '11.to_s *2' converts the number 11 to binary > when '11.to_s * 2' and 11.to_s*2 both do string multiplication as > expected. Especially since whitespace isn't supposed to matter. > > FWIW, ruby will warn you about ambiguous syntax if you run it with warnings turned on. This code: puts 11.to_s * 2 puts 11.to_s *2 puts 11.to_s*2 Outputs: $ ruby -w test_warnings.rb test_warnings.rb:2: warning: `*' interpreted as argument prefix 1111 1011 1111 pete --bcaec501c5dc56428904b39812ee--