From: "Jan E." Date: 2012-03-18T09:08:24+09:00 Subject: Re: Javascript vs. Ruby - how would this look in Ruby? Hi, You shouldn't try to translate code word by word. This simply does not work (just like with natural languages). First of all, Ruby uses class based inheritance and not prototype bases inheritance. So instead of adding a method to the prototype of TimeSeries, you would open the class TimeSeries and define a new method. Defining a method is also completely different in JavaScript and Ruby. In JavaScript, you create a function object and store it in an attribute of the object. In Ruby, you simply write a method definition: class TimeSeries def append timestamp, value @data << [timestamp, value] @max_value = value unless @max_value and @max_value >= value @min_value = value unless @min_value and @min_value <= value end end Personally I find this much more intuitive and simple than the JavaScript code. -- Posted via http://www.ruby-forum.com/.