I want to avoid reevaluation of a value in method call. Untill now, I was doing this:
def some_method
@some_method ||= begin
# lot\'s of code
end
end
I don't like the bang either. I use
def some_method
@some_method_memo ||= some_method_eval
end
private
def some_method_eval
# lot's of code
end
Here eval
is shorthand for evaluation
. I like the way this reads and also that it makes the public interface concise.
I despise conventions that rely on underscores as distinguishing marks: they are both error prone and require that I remember YAMC (yet another meaningless convention). The Ada language, designed for safety-critical applications, does not allow leading, trailing, or multiple underscores. Nice idea.