Skip to content
Discussion options

You must be logged in to vote

I'm confused because in both cases it seems I'm using a local variable "before it is declared".

In hte latter case, we don't know the type of 'value', and to determine its type, we have to look at the RHS. But the RHS uses 'value', whose type we are trying to figure out. So we can't figure out the type of the RHS. So we can't figure out the type of 'value'.

In the former case, there is no issue. we knwo the type. It is explicit. It is 'int'.

As such, we don't have to go figure out the type. We can just bind and compile the RHS. The RHS is perfectly legal. The variable is never read before it is written, for example.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@CyrusNajmabadi
Comment options

@ViIvanov
Comment options

@CyrusNajmabadi
Comment options

Answer selected by CyrusNajmabadi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants