2
Share
Share on Mastodon
Share on Twitter
Share on Facebook
Share on Linkedin
Alessandro Fazzi

@noelrap @pointlessone @geeksam I feel your point; and I'm asking myself that question everyday I review something related to that code! 😅 but, given your facts, evaluating an instance or re-binding a method or everything else so much dynamic it's not only strange in a dumb scenario as the one in my example, but it's harder to follow for less experienced programmers. High in the (domain) stack I'm usually forced to produce simplest design possible. `protected` sounded simpler to peers that time.

0
6mo
PointlessOne

@noelrap @alessandrofazzi @geeksam I hear what you're saying. However…

"Usually" means usually. It is a very specific thing in Ruby and its use is limited. That's all I read in that statement. I don't see it as "stay away”. It's more like “if you don't know the difference you probably want that other thing, if you do all power to you”.

As for “this is slow”… It might be slow. If it’s on a hot path you probably should benchmark it. As I said, it's a rather rare thing so it might not have been optimized. Or it might have been. That comment was added 8 years ago, in 2.5. A lot of things have changed since then so that particular part might not hold any more. And it's not like instance_eval docs say “this is fast”. ;)

I'm not blaming you for trusting documentation. After all, that’s the primary source. But documentation is not infallible and some parts of it might be more trustworthy than others.

0
6mo
Replies