Question

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?

Was it helpful?

Solution

Use the magic of your brain.

There is no tool that does that (to my knowledge). I would recommend you just rename the javascript to .rb and fix the syntax errors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top