Having an anonymous module owning a method is a correct approach. It’s not a matter of taste, it’s plain right and clean.
I'm not saying it's wrong or bad, it's obviously right in the context of how Ruby works. I'm just saying it seems weird if you read it.
To add a method named fly to an object mario I have to extend with a method inside an anonymous module that's going to be "injected" inside mario.
In Python this reads: to add a method named fly to an object mario I have to attach it to mario.
This is what I meant with "I find more explicit and clear".
Any way you put it metaprogramming is super cool, in each language I come across of it :-)
Thanks for the reminder about Elixir, I need to get around it sooner or later.
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.
I'm not saying it's wrong or bad, it's obviously right in the context of how Ruby works. I'm just saying it seems weird if you read it.
To add a method named fly to an object mario I have to extend with a method inside an anonymous module that's going to be "injected" inside mario.
In Python this reads: to add a method named fly to an object mario I have to attach it to mario.
This is what I meant with "I find more explicit and clear".
Any way you put it metaprogramming is super cool, in each language I come across of it :-)
Thanks for the reminder about Elixir, I need to get around it sooner or later.