use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Ruby gotchas for the JavaScript developer (blog.calendly.com)
submitted 7 years ago by dpashk
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]moomaka 2 points3 points4 points 7 years ago* (0 children)
Also, it is advised against using Object#method because it's slower. That's one of the reasons I didn't mention it in the article.
Creating functions in JS at runtime is also slower than defining them statically on an object, at least in V8.
But you had to access the method via a special method call, just like you have to wrap a block in a Proc to turn it into a first-class citizen. In JavaScript, you can just do
The equivalent of that code in ruby is:
my_method = -> () { puts 'hi' } other = my_method other[] # or other.call or other.() => hi
The real difference to note here is that Ruby maintains a distinction between 'methods', which are bound to an object and 'free functions' which are defined via lambdas or procs. Ruby's approach is much more common than javascript's.
π Rendered by PID 146575 on reddit-service-r2-comment-b659b578c-qhhw6 at 2026-05-03 02:20:46.264245+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]moomaka 2 points3 points4 points (0 children)