Skip to content

Instantly share code, notes, and snippets.

@greyblake
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greyblake/b8ebc796ce687f7c0d15 to your computer and use it in GitHub Desktop.
Save greyblake/b8ebc796ce687f7c0d15 to your computer and use it in GitHub Desktop.
Method visibility declaration
# Since ruby 2.1, method definition returns a name of a method as a symbol.
# Example:
def aaa; end # => :aaa
# How we do it currently
class SomeClass
def pub_meth
# ...
end
private
def private_meth1
# ...
end
def private_meth2
# ...
end
end
# And that's how we can do it now
class SomeClass
def pub_meth
# ...
end
private def private_meth1
# ...
end
private def private_meth2
# ...
end
end
# Benefits: the code is easier to read, we don't have to scroll up to verify
# method visibility (if we keep this convention)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment