You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = a.map { |f| f.name } #=> error: can't infer block type, try to cast the block body with `as`
```
Here `Foo` was never instantiated so the compiler has no way of knowing what the type of `@name` is.
To solve this, cast the block body with `as`:
```crystal
x = a.map { |f| f.name.as(String) } # works
```
In the future we want to get rid of this error messages and make the compiler smarter. In the above case `@name` could be deduced to be `Void` or `NoReturn`, but for now you have to use this workaround.