Skip to main content
added 3 characters in body
Source Link
Eran
  • 395k
  • 57
  • 726
  • 793

this inside lambda doesn't mean the same as this inside an anonymous inner class instance.

Inside a lambda it refers to the enclosing class.

...the lambda expression does not introduce a new level of scoping. Consequently, you can directly access fields, methods, and local variables of the enclosing scope. ... To access variables in the enclosing class, use the keyword this. ...

Inside an instance of an anonymous class, it refers to the current object

Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called

That's why in the lambda expression, this == current is never true, since it compares an instance of class ItemList with a lambda expression of type OnClickListener.

this inside lambda doesn't mean the same as this inside an anonymous inner class.

Inside a lambda it refers to the enclosing class.

...the lambda expression does not introduce a new level of scoping. Consequently, you can directly access fields, methods, and local variables of the enclosing scope. ... To access variables in the enclosing class, use the keyword this. ...

Inside an instance of an anonymous class, it refers to the current object

Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called

That's why in the lambda expression, this == current is never true, since it compares an instance of class ItemList with a lambda expression of type OnClickListener.

this inside lambda doesn't mean the same as this inside an anonymous class instance.

Inside a lambda it refers to the enclosing class.

...the lambda expression does not introduce a new level of scoping. Consequently, you can directly access fields, methods, and local variables of the enclosing scope. ... To access variables in the enclosing class, use the keyword this. ...

Inside an instance of an anonymous class, it refers to the current object

Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called

That's why in the lambda expression, this == current is never true, since it compares an instance of class ItemList with a lambda expression of type OnClickListener.

added 175 characters in body
Source Link
Eran
  • 395k
  • 57
  • 726
  • 793

this inside lambda doesn't mean the same as this inside an anonymous inner class.

Inside a lambda it refers to the enclosing class.

...the lambda expression does not introduce a new level of scoping. Consequently, you can directly access fields, methods, and local variables of the enclosing scope. ... To access variables in the enclosing class, use the keyword this. ...

Inside an instance of an anonymous inner class, it refers to the innercurrent object

Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called

That's why in the lambda expression, this == current is never true, since it compares an instance of class ItemList with a lambda expression of type OnClickListener.

this inside lambda doesn't mean the same as this inside an anonymous inner class.

Inside a lambda it refers to the enclosing class.

...the lambda expression does not introduce a new level of scoping. Consequently, you can directly access fields, methods, and local variables of the enclosing scope. ... To access variables in the enclosing class, use the keyword this. ...

Inside an anonymous inner class, it refers to the inner class.

this inside lambda doesn't mean the same as this inside an anonymous inner class.

Inside a lambda it refers to the enclosing class.

...the lambda expression does not introduce a new level of scoping. Consequently, you can directly access fields, methods, and local variables of the enclosing scope. ... To access variables in the enclosing class, use the keyword this. ...

Inside an instance of an anonymous class, it refers to the current object

Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called

That's why in the lambda expression, this == current is never true, since it compares an instance of class ItemList with a lambda expression of type OnClickListener.

Source Link
Eran
  • 395k
  • 57
  • 726
  • 793

this inside lambda doesn't mean the same as this inside an anonymous inner class.

Inside a lambda it refers to the enclosing class.

...the lambda expression does not introduce a new level of scoping. Consequently, you can directly access fields, methods, and local variables of the enclosing scope. ... To access variables in the enclosing class, use the keyword this. ...

Inside an anonymous inner class, it refers to the inner class.