34 points | by zemptime 3 days ago
5 comments
Please fix the indentation of the code -_-
It's an interesting trick, but for a setter method you really need to use `def cloaking=(value)` instead of overloading the same method. It would help to give a more realistic example for where this technique can be useful.
What happens if you pass in (nothing_provided = true) as the value?
Does it return back the empty current value?
I’m no ruby expert, but seems like the freeze approach avoids that with a unique inaccessible object.
Wow, I wrote Ruby for 15+ years and never saw this trick!
Same and it’s really unclear to me why you would want this access pattern over. It seems like it might lead to unintended consequences.
Please fix the indentation of the code -_-
It's an interesting trick, but for a setter method you really need to use `def cloaking=(value)` instead of overloading the same method. It would help to give a more realistic example for where this technique can be useful.
What happens if you pass in (nothing_provided = true) as the value?
Does it return back the empty current value?
I’m no ruby expert, but seems like the freeze approach avoids that with a unique inaccessible object.
Wow, I wrote Ruby for 15+ years and never saw this trick!
Same and it’s really unclear to me why you would want this access pattern over. It seems like it might lead to unintended consequences.