Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

書籍 Ruby Cookbook | 配列一括設定

パンくず

Ruby Cookbook
配列一括設定

概要

配列一括設定

サンプル

array = [:one,:two,:three]
a,b,c=array
puts "#{a},#{b},#{c}"
array << :four << :five
a,b,*c=array
puts "#{a},#{b},#{c}"

出力

one,two,three
one,two,[:three, :four, :five]