Given the following code:
def map(char, charmap)
unless map = charmap[[char]]
unless map = charmap[[char, c = input.getc]]
input.ungetc(c) if c
map = ''
end
end
map
end
What is the double square brackets doing?
Thanks
It is application of the method
[]taking an array as the argument.Since the OP did not make clear, we cannot tell what
charmapis, but for example if it were a hash, thencharmap[[char, c = input.getc]]would return the value incharmapthat corresponds to the key[char, input.getc].