2020-11-12から1日間の記事一覧
やりたいこと 以下の文章から、onという文字だけを抜き出したい。 I have a dream that one day on the red hills of Georgia, the sons of former slaves and the sons of former slave owners will be able to sit down together at the table of brotherh…
rejectメソッドを使った場合。 #空文字が入った配列 ary = ["hoge", "bar", "", "baz"] p ary.reject { |el| el.empty? } => ["hoge", "bar", "baz"] 省略すると以下のように書ける。 p ary.reject(&:empty?) => ["hoge", "bar", "baz"] rejectメソッドは、…