はじめに
移植やってます。
( from python 3.7 to ruby 2.7 )
!r (Python)
>>> name = "Fred"
>>> f"He said his name is {name!r}."
"He said his name is 'Fred'."
>>> f"He said his name is {repr(name)}." # repr() is equivalent to !r
"He said his name is 'Fred'."
'!r' は repr() を呼び出します。
どうする (Ruby)
name = "Fred"
puts "He said his name is #{__repr__(name)}."
# or
puts "He said his name is #{name.inspect}."
!r
を検索するのに時間がかかりました。
メモ
- Python の !r を学習した
- 百里を行く者は九十里を半ばとす