Ruby 文字列を初期化するサンプル

環境
Windows11 pro 64bit
ruby ruby 3.0.3p157

構文
文字列.clear
文字列を初期化するには「clear」を使用します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
str = "test111"
str.clear
p str
str = "test111" str.clear p str
str = "test111"

str.clear

p str

結果
“"

Ruby

Posted by arkgame