JavaScript in Ruby
I want to replicate any given Javascript l开发者_如何学Coop , 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?
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.
精彩评论