RosettaCodeData/Task/Associative-array-Creation/Crystal/associative-array-creation.cr
2024-10-16 18:07:41 -07:00

5 lines
280 B
Crystal

hash1 = {"foo" => "bar"}
# hash literals that don't perfectly match the intended hash type must be given an explicit type specification
# the following would fail without `of String => String|Int32`
hash2 : Hash(String, String|Int32) = {"foo" => "bar"} of String => String|Int32