This post originated from an RSS feed registered with Ruby Buzz
by Matt Williams.
Original Post: Overriding operators: two dimensional arrays
Feed Title: Ruby Blender
Feed URL: http://feeds2.feedburner.com/RubyBlender
Feed Description: This blog contains short-ish ruby tips, hints, and techniques.
One of the neat things about ruby is that, in general, operators are methods, so they can be overridden. When working with multidimensional arrays, some languages allow you to do the following: Text | copy code |?1a[0,0] whereas ruby uses: Ruby | copy code |?1a[0][0] Which makes sense, since Ruby implements it as an array of arrays and you’re chaining methods to [...]