Originally posted by Rick O'Shay:
This achieves the same result with the added benefit of always working.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Rick O'Shay:
The compiler doesn't know push from put from set from shinola.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Rick O'Shay:
My suggestion, getting back to the original question, is to use this because it achieves the same result with the added benefit that it always works, no pesky problems with add and so forth:
Container<Value> container = new Container<Value>();
I then expanded that to say you can avoid these problems using wild cards only when defining generic methods and classes.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Rick O'Shay:
Oh, wait. I must have accidentally changed "get" to "add". In other words, we're going in circles. I understand entirely that you example can and will and does work, but notice how in general it does not.
I think really that's the only disagreement. I'm saying it's not orthogonal and it's not even consistent so you lose more than you gain.
I was pointing out that David's interpretation was wrong: you cannot add through wild card bounded references was the claim. That's not the case, it's ANY method that accepts a generic parameter.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Container<? super IFace> means you can put an IFace in but you can't take one out.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Rick O'Shay:
What do you mean "lookup your example"? Wasn't the snippet I posted essential the example you had in mind? Show me where the example and I'll review it with respect to my proposed use policy for the wild card. I thought that was it but apparently not.
BTW, we have 21 messages and still getting entirely wrong assertions about the purpose of wild cards:
>> The purpose of a wildcard is to hide parts of the interface that shouldn't be used
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
"I'm not back." - Bill Harding, Twister
"I'm not back." - Bill Harding, Twister
"I'm not back." - Bill Harding, Twister
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Rick O'Shay:
I would also add the following. A new requirement comes in. The solution requires a method call through the wild card reference. It won't compile because it accepts a type parameter. UPSADAISY! You need a specific type reference. So much for change insulation.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Don't get me started about those stupid light bulbs. |