Access the caller instance from a function.

43 weergaven
Naar het eerste ongelezen bericht

Gonzalo Chumillas

ongelezen,
18 jul 2016, 12:05:3818-07-2016
aan Dart Misc
How could I access the "caller" instance from a function. The following code throws a syntax error:

// Error: Local variables cannot be referenced before they are declared
Function listener = (Event event) {
 
print(listener);
};

I would like to access the "listener" variable from inside the function.
Thanks.

Gonzalo Chumillas

ongelezen,
18 jul 2016, 13:01:3518-07-2016
aan Dart Misc
What a silly question :D Solved:

Function listener;

listener
= (Event event) {
 
print(listener);
}

Bob Nystrom

ongelezen,
18 jul 2016, 13:36:2818-07-2016
aan General Dart Discussion
Or even:

  listener(Event event) {
    print(listener);
  }

:)

– bob


--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

Gonzalo Chumillas

ongelezen,
18 jul 2016, 14:44:1918-07-2016
aan Dart Misc
Thanks :) I like it even better.
Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten