Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

デリゲートのスコープの問題[FEATURE_REQUEST] #24

Closed
taiseiue opened this issue Mar 14, 2023 · 0 comments
Closed

デリゲートのスコープの問題[FEATURE_REQUEST] #24

taiseiue opened this issue Mar 14, 2023 · 0 comments

Comments

@taiseiue
Copy link
Contributor

デリゲートを使ってイベントを実装しているとき、C#のように次のように記述したい時がある。

var count = 0;
onclick += _=>print(count++);

しかしこのコードは期待通りに動作しない。なぜなら、onclickのスコープは呼び出し元にあって定義したところのスクリプトにはないからである。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant