Discussion:
[dart-misc] Access the caller instance from a function.
Gonzalo Chumillas
2016-07-18 16:05:38 UTC
Permalink
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.
--
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+***@dartlang.org.
Gonzalo Chumillas
2016-07-18 17:01:35 UTC
Permalink
What a silly question :D Solved:

Function listener;
listener = (Event event) {
print(listener);
}
Post by Gonzalo Chumillas
How could I access the "caller" instance from a function. The following
// 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.
--
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+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2016-07-18 17:35:54 UTC
Permalink
Or even:

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

:)

– bob


On Mon, Jul 18, 2016 at 10:01 AM, Gonzalo Chumillas <
Post by Gonzalo Chumillas
Function listener;
listener = (Event event) {
print(listener);
}
Post by Gonzalo Chumillas
How could I access the "caller" instance from a function. The following
// 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.
--
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
--
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+***@dartlang.org.
Gonzalo Chumillas
2016-07-18 18:44:18 UTC
Permalink
Thanks :) I like it even better.
Post by 'Bob Nystrom' via Dart Misc
listener(Event event) {
print(listener);
}
:)
– bob
Post by Gonzalo Chumillas
Function listener;
listener = (Event event) {
print(listener);
}
Post by Gonzalo Chumillas
How could I access the "caller" instance from a function. The following
// 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.
--
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
--
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+***@dartlang.org.
Loading...