Skip to content

Instantly share code, notes, and snippets.

@mverzilli
Created January 9, 2017 15:33
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 mverzilli/3112e642f5c2f9eb2d171cfeb75f09e3 to your computer and use it in GitHub Desktop.
Save mverzilli/3112e642f5c2f9eb2d171cfeb75f09e3 to your computer and use it in GitHub Desktop.
Crystal case in types vs. values
def get()
if 2 > 1
{"String", {"foo" => "bar"}}
else
nil
end
end
x = get
case x; when {String, Hash}; p typeof(x); end
x = get
case x; when Tuple(String, Hash(String, String)); p typeof(x); end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment