Great article Jeremy! Thanks.
Funny because I didn't know what extension methods were and instead of some voodoo thing they are just what you can achieve in Ruby with open classes:
2.6.1 :001 > class String 2.6.1 :002?> def mutate() 2.6.1 :003?> return self + " mutation" 2.6.1 :004?> end 2.6.1 :005?> end => :mutate 2.6.1 :006 > s = "Hello, world!" => "Hello, world!" 2.6.1 :007 > s.mutate => "Hello, world! mutation"
or JavaScript extensions using prototype inheritance:
> String.prototype.mutate = function() { return this + " mutation"; } > a = "Hello, world!" > a.mutate() "Hello, world! mutation"
Optional chaining should be added to all languages with the concept of null π
null
en.wikipedia.org/wiki/Extension_me...
"The Ruby community often describes an extension method as a kind of monkey patch." π
But yes, they can be useful.
Wow. Clearly, I havenβt played around enough with ruby or JavaScript. I really thought Kotlin was changing the game. Haha thanks for the tip!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article Jeremy! Thanks.
Funny because I didn't know what extension methods were and instead of some voodoo thing they are just what you can achieve in Ruby with open classes:
or JavaScript extensions using prototype inheritance:
Optional chaining should be added to all languages with the concept of
null
πen.wikipedia.org/wiki/Extension_me...
"The Ruby community often describes an extension method as a kind of monkey patch." π
But yes, they can be useful.
Wow. Clearly, I havenβt played around enough with ruby or JavaScript. I really thought Kotlin was changing the game. Haha thanks for the tip!