Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumRubypattern matching case inSingle-choice MCQ

Given a Struct, which deconstruction patterns match?

Point = Struct.new(:x, :y) p = Point.new(1, 2) r1 = (p in [a, b]) r2 = (p in {x:, y:}) puts "#{r1} #{r2}"