Created
September 3, 2013 10:14
-
-
Save yuanfeiz/6422067 to your computer and use it in GitHub Desktop.
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
class User | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
def say_my_name | |
puts @name | |
end | |
def say_hi | |
name = "myname" | |
puts name | |
end | |
def self.say_hi | |
"I'm a class" | |
end | |
end | |
xiaomin = User.new("小明") | |
puts xiaomin.name | |
puts User.say_hi | |
xiaomin.say_hi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment