I found this pretty old blog post about converting JavaScript code to Ruby code . However, the gems used in the examples (both rkelly and ruby2ruby ) seem to have changed a lot over the past 7 years, and now these examples do not work with them. I tried to play with gems a bit, but I am not a Ruby expert, and I have no experience in analyzing and processing languages, so my attempts were not successful.
My question is: is there another way to convert JavaScript code to Ruby code with these gems? And if so, how?
, - . , . , , Google Translate.
- JavaScript, Ruby, JavaScript Ruby .
JavaScript, , Ruby. , , .
, JavaScript:
var count = 0; _.each(array, function(e) { count += Math.pow(2, e); }) return count;
Ruby:
array.inject(0) do |s, e| s + 2 ** e end
, API .
Source: https://habr.com/ru/post/1543441/More articles:Matplotlib text transformation - pythonto stop an idle event in the Google Maps API v3 - javascriptHow to remove a new item from a queue in a queue - c #Integration of WPF, Unity3D (and Kinect) - c #What is the value of the typedef function int (void *)? - cError code Android Studio 0.5.9 42 - androidRails 4: ะััั ะปะธ first_or_initialize ะดะปั ะฐััะพัะธะฐัะธะธ has_one? - ruby-on-railsSlick and bonecp: org.postgresql.util.PSQLException: FATAL: sorry, too many clients are already mistaken - scalaUnable to read the noConflict property from undefined (Chrome extension) - javascriptDelegate not invoked in iOS SWIFT - iosAll Articles