LoginSignup
5
0

More than 5 years have passed since last update.

to_sメソッドはnilを""で返してくれる

Posted at

取得した値がnilの場合、""してくれるやり方ないかなと調べていたら、いとも簡単な方法が見つかった。
a = nilの場合
a.to_sは、""となる。

すげ〜、ifで場合分けする必要なし!!

5
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0