Lambda Lambda

Richard Bair richard.bair at oracle.com
Thu Mar 20 20:06:00 UTC 2014


I don’t know.

On Mar 20, 2014, at 1:03 PM, Scott Palmer <swpalmer at gmail.com> wrote:

> So why doesn't this complain:
> n.managedProperty().<ChangeListener>addListener(x -> test(x));
> 
> "ChangeListener" has no business being there.
> 
> Scott
> 
> On Thu, Mar 20, 2014 at 4:02 PM, Scott Palmer <swpalmer at gmail.com> wrote:
>> Thanks.. just figured that out myself.
>> As my colleague just said to me "the world is good again"
>> 
>> On Thu, Mar 20, 2014 at 4:00 PM, Richard Bair <richard.bair at oracle.com> wrote:
>>> InvalidationListener has one param, ChangeListener has 3. So the arity of the lambda tells the compiler which kind to produce. If there was ambiguity, the compiler would complain.
>>> 
>>> Richard
>>> 
>>> On Mar 20, 2014, at 12:54 PM, Scott Palmer <swpalmer at gmail.com> wrote:
>>> 
>>>> So I'm looking at Java 8 stuff now and I see that addListener has
>>>> methods.  One takes a ChangeListener, the other an
>>>> InvalidationListener.
>>>> 
>>>> So what does this do:
>>>> 
>>>> Node n = getSomeNode();
>>>> n.managedProperty().addListener(x -> test(x));
>>>> 
>>>> Well it seems it adds an InvalidationListener.
>>>> 
>>>> So I tried this:
>>>> 
>>>> n.managedProperty().<ChangeListener>addListener(x -> test(x));
>>>> 
>>>> which seems to be accepted syntax, but it still adds an InvalidationListener !!!
>>>> 
>>>> Help Please.
>>>> 
>>>> Why didn't JavaFX 8 add two new methods:
>>>> addChangeListener
>>>> addInvalidationListener
>>>> 
>>>> ?
>>>> 
>>>> Scott
>>> 



More information about the openjfx-dev mailing list