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

"Casting to method" issue #7114

Closed
Xample opened this issue Feb 17, 2016 · 2 comments
Closed

"Casting to method" issue #7114

Xample opened this issue Feb 17, 2016 · 2 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@Xample
Copy link

Xample commented Feb 17, 2016

Hi, I faced a problem unable to cast an object as a method. While this is handled automatically using an if / else block (and congratulation to the guys who implemented this), this is not working yet into a switch case nor manually. Here is my code to reproduce the error:

@RyanCavanaugh
Copy link
Member

You can use parentheses to make the type assertion work (what you had was changing the type of the result, not the thing being invoked):

case "function" : (<MethodInterface>actionOrString)();

Otherwise this is a duplicate of #2214

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Feb 17, 2016
@mhegazy mhegazy closed this as completed Feb 17, 2016
@Xample
Copy link
Author

Xample commented Feb 17, 2016

Thank you @RyanCavanaugh !

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants