Skip to content

Instantly share code, notes, and snippets.

@hinrik
Created November 12, 2017 10:35
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 hinrik/afb7ac00748b88fcbb15515c0f918100 to your computer and use it in GitHub Desktop.
Save hinrik/afb7ac00748b88fcbb15515c0f918100 to your computer and use it in GitHub Desktop.
alias IntOrNil = Array(Int32 | Nil)
mixed = [4, 5, nil]
ints = [6, 7]
array_storage = [] of IntOrNil
array_storage << mixed
array_storage << ints
hash_storage = {} of IntOrNil => Int32
hash_storage[mixed] = 1
hash_storage[ints] = 2 # This gives:
# in src/hash.cr:45: instantiating 'insert_in_bucket(Int32, Array(Int32), Int32)'
#
# entry = insert_in_bucket index, key, value
# ^~~~~~~~~~~~~~~~
#
# in src/hash.cr:854: instantiating 'Hash::Entry(Array(Int32 | Nil), Int32):Class#new(Array(Int32), Int32)'
#
# return entry.next = Entry(K, V).new(key, value)
# ^~~
#
# in src/hash.cr:898: instance variable '@key' of Hash::Entry(Array(Int32 | Nil), Int32) must be Array(Int32 | Nil), not Array(Int32)
#
# def initialize(@key : K, @value : V)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment