label methods: private or protected will have the indicated visibility until changed or until the definition ends.
def initialize( given, family, nick, pet )
@given = given
@family = family
@nick = nick
@pet = pet
# these methods are public by default
# all following methods private, until changed
# all following methods protected, until changed
name = Names.new( "Klyde", "Kimball", "Abner", "Teddy Bear" )
name.given # => "Klyde"
name.family # => "Kimball"
# see what happens when you call nick or pet
Related examples in the same category