NamedTuple isn't Enumerable


#1

Consider this example:

def foo(bar : Enumerable(String))
  pp! bar
end

foo({"baz"})
foo(["baz"])

It works nice, because Tuple includes Enumerable.

But this code:

def foo(bar : Enumerable({String, String}))
  pp! bar
end

foo({"baz" => "qux"})
foo({"baz": "qux"})

Doesn’t compile with

no overload matches 'foo' with type NamedTuple(baz: String)

Shouldn’t this behavior change? NamedTuple already has #each methods and its keys could be considered Strings…


#2

I think I’ve had the same question before…FWIW :)