rails consoleにて
>> class String >> def palindrome? >> self == self.reverse >> end >> end
と
>> def palindrome? >> self == self.reverse >> end
どちらでも
>> "deified".palindrome? => true
と同じ挙動をします。
classとはどういう時に使うべきであって、使う必要がない時はどのような時なのか知りたいです。よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/01/24 05:21
2022/01/24 06:01
2022/01/24 06:45
2022/01/24 07:13