Skip to content

Instantly share code, notes, and snippets.

@Altreus
Last active July 23, 2020 13:59
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 Altreus/f0a2170378f31562779379692de8de8b to your computer and use it in GitHub Desktop.
Save Altreus/f0a2170378f31562779379692de8de8b to your computer and use it in GitHub Desktop.
> my %image-formats = JPEG => '.jpeg', PNG => '.png', WebP => '.webp', GIF => '.gif';
{GIF => .gif, JPEG => .jpeg, PNG => .png, WebP => .webp}
> subset ImageFormat of Str where * ~~ %image-formats;
(ImageFormat)
> sub f(ImageFormat :$format = "PNG") { say $format }
&f
> f()
Constraint type check failed in binding to parameter '$format'; expected ImageFormat but got Str ("PNG")
in sub f at <unknown file> line 1
in block <unit> at <unknown file> line 1
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment