I’m new to this forum, so I don’t know if it’s the right place to
discuss this. I still give it a try:
I’d love to see a non-verbose way of defining one-line methods in Ruby.
This would especially be useful for methods with constant return value,
for the sake of duck typing. For example,
def visible?
true
end
It would be much nicer if we could write these methods like
I agree with you that the return value isn’t apparent at first sight,
also the semicolon looks somehow alien here.
That’s why I’d like a shorthand notation that’s both, short and clear.
For modules/classes I prefer to write
Role = Module.new
This way I don’t need the semicolon and the end for the same reasons
mentioned above. But since methods aren’t objects in Ruby, this approach
doesn’t work here.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.