Why variable names cannot have ? or ! in Ruby but method names can
I had this question and found a good discussion on StackOverflow
There is a difference as a variable holds a specific value whereas one single method could return values of different types. However, from a semantic point of view:
Methods are messages sent to an object, so you could tell the object do do something or ask it for a value (hence the question mark). Variables are just holding a certain value.
Written by Peter Zhang
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Tags
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#