gets.inspect
=>"chocolate\n"
文字列を比較するとしたら、こうだろうか。
a=gets.chomp
a.eql? "chocolate"
Integerの引数は数値でなければ例外(改行コードは許容)を投げるが、to_iは引数に数値が含まれていれば値を返す。
参考:https://stackoverflow.com/questions/10093493/difference-between-integervalue-and-value-to-i/10093572#10093572
chomp!の!が付く関数は"dangerous methods"と呼ばれ、呼び出し元のオブジェクトに変更を加える関数。
参考:https://stackoverflow.com/questions/612189/why-are-exclamation-marks-used-in-ruby-methods
小文字またはアンダーバー(_)で始まる変数は「ローカル変数」
@ で始まる変数は「インスタンス変数」
@@で始まる変数は「クラス変数」
ドル記号($) で始まる変数は「グローバル変数」
大文字で始まる識別子は「定数」
nilは未定義値
参考:http://www.tohoho-web.com/ruby/variables.html