-
-
Save mistyrinth/35b2784cea74acf7103897582ceb860d 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 Car | |
def accele(acceletime=1) | |
puts "アクセルを踏みました" | |
puts "スピードは#{calcSpeed(acceletime)}kmです" | |
end | |
public :accele | |
def calcSpeed(acceletime) | |
return acceletime * 10 | |
end | |
private :calcSpeed | |
end | |
# オブジェクトの作成 | |
car = Car.new | |
# publicメソッドの実行 | |
car.accele(10) | |
# privateメソッドの実行 → エラーになる | |
car.calcSpeed(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment