From: Simon Strandgaard Date: 2004-04-06T04:39:20+09:00 Subject: Re: [bug] Array#fetch weird second argument On Tue, 06 Apr 2004 05:23:07 +0900, Peter wrote: >> While adding a testcase to rubicon for Array#fetch, I discovered that >> #fetch takes a second argument. However I cannot figure out what its >> purpose are. I have tried with lots of different input. >> >> server> irb >> irb(main):001:0> %w(a b c).fetch(1, 500) >> => "b" >> irb(main):002:0> %w(a b c).fetch(1, -9) >> => "b" >> irb(main):003:0> %w(a b c).fetch(1, nil) >> => "b" > > irb(main):004:0> %w(a b c).fetch(10) > IndexError: index 10 out of array > from (irb):10:in `fetch' > from (irb):10 > from :0 > irb(main):005:0> %w(a b c).fetch(10, 500) > => 500 > > Peter Ah.. Bommer. I see the second argument is the default value. Thanks for straighten this out. -- Simon Strandgaard