From: Tom Clarke Date: 2012-02-09T01:56:06+09:00 Subject: Require bug confirmation: possible 'times' method error --20cf307f314244a26a04b876c5b0 Content-Type: text/plain; charset=ISO-8859-1 Hi all, First time posting here. I'm a Ruby newbie, so apologies if this question sounds dumb. I've found something I'm unable to explain. It's either a 'bug' or a confusing feature. See code below (taken from rubylearning.com): --- "# p019mtdarry.rb # if you give return multiple parameters, # the method returns them in an array # The times method of the Integer class iterates block num times, # passing in values from zero to num-1 def mtdarry 10.times do |num| square = num * num return num, square if num > 5 end end # using parallel assignment to collect the return value num, square = mtdarry puts num puts square" --- The output is meant to be as follows: --- ">ruby p019mtdarry.rb 6 36 >Exit code: 0" --- This is the output for the code above. However, if I change 10.times to 6.times, the 'puts num' output is 6, and the square output is blank. The reason this is odd is, if the values for num go from 0 to 5, then the output of puts num should be 5. However, as the output of puts num is 6, then the puts square output should be 36, but instead it is blank. I've tested this on both Ruby 1.9.2 and 1.9.3 (p0). My question is, should I raise this as a bug or have I missed something in my program analysis? Thanks, Tom --20cf307f314244a26a04b876c5b0--