Last active
August 29, 2015 14:15
-
-
Save greyblake/b8ebc796ce687f7c0d15 to your computer and use it in GitHub Desktop.
Method visibility declaration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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