From: Dave Thomas Date: 2000-12-04T00:38:46+09:00 Subject: [ruby-talk:6769] Re: printing/accessing arrays and hashes matz@zetabits.com (Yukihiro Matsumoto) writes: > Probably Hash#fetch equivalent for Array is good answer. What do you > guys think is the best name for it? Array#get? Array#fetch? at (for the Smalltalkers out there). > This is iteresting comment. Let's discuss. If index is out of > bound, what should [] return? nil or empty array? We need to choose an underlying semantic. For me, the primitive operation here is array element indexing, a[]. Everything else is defined in terms of it. a[x..y] should return [ a[x] + a[x.succ] ...a[y] ] So, if a = [9, 8, 7] a[0] = 9 a[1] = 8 a[2] = 7 a[3] = nil a[4] = nil a[1,2] = [ a[1], a[2] ] => [ 8, 7 ] a[1,4] = [ a[1], a[2], a[3], a[4] ] => [ 8, 7, nil, nil ] a[5,2] = [ a[5], a[6] ] => [ nil, nil ] a[2..5] = [ a[2], a[3], a[4], a[5]] => [ 7, nil, nil, nil ] Regards Dave ps. How did the conference go? Will anyone be posting a report?