my_namedtuple : ??? = {name : “unknown”, job : “coder”}
my_hash : ??? = {“name” => “unknown”, “job” => “code”}
my_namedtuple : ??? = {name : “unknown”, job : “coder”}
my_hash : ??? = {“name” => “unknown”, “job” => “code”}
Depends on the data types of the named tuple itself. But basically It’s NamedTuple, then a list of the key names and their types.
my_namedtuple : NamedTuple(name: String, job: String) = {name: "unknown", job: "coder"}
somethingElse : NamedTuple(foo: Int32, bar: String) = {foo: 42, bar: "Crystal <3"}
no no tuple and hash what is the type of hash ?
The hash you listed is Hash(String, String). The first is the key type, the second is the value type.
named tuple doesn’t work !!!
Post your code please?
sorry it works now i just moved : one step ahead that was the issue
there is no support for regular tuple ?
There is: Tuple(*T) - Crystal 1.10.1
Note you can always get the type of an expression using typeof:
typeof({name: "unknown", job: "coder"}) # => NamedTuple(name: String, job: String)
typeof({"name" => "unknown", "job" => "code"}) # => Hash(String, String)