From: "Thomas B." Date: 2008-09-01T18:14:47+09:00 Subject: Re: arrays, difference of operation... Mayuresh Kathe wrote: > I'm a bit confused about this whole array thing, could someone please > elaborate on the above two different results for array operations? > Also, how would I seek an element in a numeric array without referring > to its index? Hello. Your confussion comes from the fact that you assume that [] means an array. In Ruby, [] means whatever you want. If a is an array, then a[index] is an operation of reading the specified element, and a[index]=value is the operation of writing the element. They can also be written as a.[](index) and a.[]=(index,value), as [] and []= are just method names. As these are methods, they can be defined differently for other classes than Array. For example, for String they are defined as "find the text (and replace it with the value)". If you define your class, you can even do this: class K def [](a,b,c) puts "#{a}:#{b}:#{c}" end end K::new[2,:f,"asd"] As you see, the result has nothing to do with arrays. It's just a method, the difference is only the fact that you can use the short notation a[x] instead of a.[](x). TPR. -- Posted via http://www.ruby-forum.com/.