I want to replicate any given Javascript loop , class , function to into its Ruby Equivalent
and e.g would as follow suppose I passed the following Javascript function.
function define() { var x = 0; for(var i=0; i < 10 ; i++) { var x += i } alert(x); } define();
then I should get replicate to the corresponding Ruby equivalent code
def define() x = 0 for i in 0...10 do x += i end puts x end define()
similarly the classes object initialization code i.e
a = new Array => in JavaScript
should get replicate to
a = Array.new
Any Thought On How I can achieve this
Thanks