do 2 def deconstruct 3 puts '`deconstruct` is called' 4 to_a # [red, green, blue] 5 end 6 end 7 8 class Color2 < Color; end 9 10 case Color[0, 10, 0] 11 in Color2[0, a, 0] # not called because type is different 12 puts "Color2" 13 in [0, a, 0] 14 puts "Matched with array: #{a}" # => 10 15 in Color[0, a, 0] # => `deconstruct` is called 16 puts "Matched with Color: #{a}" # => 10 17 end ෦తʹɺEFDPOTUSVDU͕ ฦ͢"SSBZΦϒδΣΫτΛݩ ʹύλʔϯϚον͍ͤͯ͞ Δɻ ͳͷͰɺಠࣗͷ$PMPSΫϥε ͷΦϒδΣΫτΛύλʔϯ Ϛονͤ͞Δ͜ͱՄೳʂ ͍͢͝ʂ ຊՈεϥΠυͰɺߏจΛॲཧ͢Δ3VCZ7."CTUSBDU4ZOUBY5SFF/PEFʹEFDPOTUSVDUΛ࣮ͨ͠Β 1PXFS"TTFSU͕࣮Ͱ͖ͪΌ͏తͳ͜ͱ͕ॻ͍ͯ͋Δʢཧղෆʣ