[Ruby]クラスのinitializeのサンプル
書式
def initialize
@変数名=xxx
end
使用例
#!/usr/bin/ruby
class Test
def initialize
@msg = "study skill in arkgame become smart"
end
def funcA
p @msg
end
end
cft = Test.new
cft.funcA
#!/usr/bin/ruby
class Test
def initialize
@msg = "study skill in arkgame become smart"
end
def funcA
p @msg
end
end
cft = Test.new
cft.funcA
#!/usr/bin/ruby class Test def initialize @msg = "study skill in arkgame become smart" end def funcA p @msg end end cft = Test.new cft.funcA
結果
“study skill in arkgame become smart"