开发者

JavaScript in Ruby

开发者 https://www.devze.com 2023-01-18 14:05 出处:网络
I want to replicate any given Javascript l开发者_如何学Coop , class , function to into its Ruby Equivalent

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消