From: dblack@... Date: 2006-09-25T01:28:43+09:00 Subject: Re: Use of array shift and blocks Hi -- On Mon, 25 Sep 2006, Toby Rodwell wrote: > (Something a bit more basic than the other thread about the array shfit > bug!) > > Given the following: > > myArray=["a", "b", "c", "d"] > until myArray.empty? > myArray.shift { |letter| > puts letter > } > end > > ... I would expect the letters a, b, c and d to be printed to the > screen, but I don't get anything (including no error message). Have I > misunderstood something about array shift and/or blocks? shift doesn't take a block. You can write one but shift won't call it. You could do this: until array.empty? puts array.shift end David -- David A. Black | dblack@wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org