`[]` operator on `Buffer`s?
# language-proposals
e
[]
operator on `Buffer`s?
e
elect: On what Buffers? You can always write one yourself for whatever buffer you are using (it is just one line of code)
e
I tried
it says "it's shadowed" and it doesn't work
wait
e
What buffer you are talking about. I don't understand.
e
I tried the
get
yep, it works
get
is shadowed by a member
do you think this can be a problem?
currently, however, it seems to work properly
[]
refers to the
get
operator
get
to the original
ByteBuffer.get()
e
Yes. It will.
What else would you expect
[]
or a
ByteBuffer
to do?
e
oh nothing else, but I was just wondering if this may cause some ambiguities for the compilers
because I hit a couple of times a situation where from java it said there was an ambiguity (same java signature)
d
Members win. That is, if there's an applicable class member, it will always have a priority over an extension. And yes, it kinda sucks that ByteBuffer has a get method that looks like a
[]
operator, but does something really different.