概要
Rubyについて授業で習ったのでメモ。今回は主に数値や文字列を出力する際に使う'p', 'puts', 'print'メソッドの違いを調べたのでいかに記す。
| メソッド | 改行 | 引数の型情報の表示 |
|---|---|---|
| p | o | o |
| puts | o | x |
| x | x |
また、pメソッドだと"Hellow World"という引数で出力したとき両端のタブルクオーテーションも出力される
参考ページ
I(puts)]https://qiita.com/Chinats/items/c464c3a88c263f15224b
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 3 years have passed since last update.
Rubyについて授業で習ったのでメモ。今回は主に数値や文字列を出力する際に使う'p', 'puts', 'print'メソッドの違いを調べたのでいかに記す。
| メソッド | 改行 | 引数の型情報の表示 |
|---|---|---|
| p | o | o |
| puts | o | x |
| x | x |
また、pメソッドだと"Hellow World"という引数で出力したとき両端のタブルクオーテーションも出力される
I(puts)]https://qiita.com/Chinats/items/c464c3a88c263f15224b
Register as a new user and use Qiita more conveniently
Go to list of users who liked