Skip to content

Instantly share code, notes, and snippets.

@fnordfish
Created July 15, 2022 07:05
Show Gist options
  • Save fnordfish/82137e3017ae47a59a92d5a52eaad20f to your computer and use it in GitHub Desktop.
Save fnordfish/82137e3017ae47a59a92d5a52eaad20f to your computer and use it in GitHub Desktop.
Dry-Types Coercible::Set like Coercible:Array
Coercible::Set = Types.Constructor(
Set,
->(a) {
# mock behavior of `Kernel.Array`
case a
when nil then Set.new
when Enumerable then Set.new(a)
else Set[a]
end
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment