Skip to content

Instantly share code, notes, and snippets.

@baweaver
Created December 14, 2019 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baweaver/552e5e8252e9cccc185f245524ab074a to your computer and use it in GitHub Desktop.
Save baweaver/552e5e8252e9cccc185f245524ab074a to your computer and use it in GitHub Desktop.
Cons = Struct.new(:head, :tail)
case Cons[1, Cons[2]]
in Cons[head. tail] then [head, tail]
end
# => [1, #<struct Cons head=2, tail=nil>]
case Cons[1, Cons[2]]
in Cons[1, Cons[head, tail]] then [head, tail]
end
# => [2, nil]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment