title, *, body = "1行目\n2行目\n3行目".partition("\n")
puts title # => 1行目
puts body # => 2行目\n3行目
https://ruby-doc.org/core-2.4.0/String.html#method-i-partition
Rubyの多重代入あれこれまとめ - Qiita
コメント欄も見て行ってくれよな!
Go to list of users who liked
More than 5 years have passed since last update.
title, *, body = "1行目\n2行目\n3行目".partition("\n")
puts title # => 1行目
puts body # => 2行目\n3行目
https://ruby-doc.org/core-2.4.0/String.html#method-i-partition
Rubyの多重代入あれこれまとめ - Qiita
コメント欄も見て行ってくれよな!
Register as a new user and use Qiita more conveniently
Go to list of users who liked