#if statement scope thingy

1 messages · Page 1 of 1 (latest)

blazing fern
#

im trying to access variable outside this if statement

hasty phoenixBOT
#

<@&987246399047479336> please have a look, thanks.

golden turret
#

in this case dont use an if else in the first place

summer estuary
#

boolean repeat = repeatInput.equalsIgnoreCase("y");
What's stopping you from doing this?

#

Otherwise you can declare the variable before the block boolean repeat;

obsidian knoll
#

the first layer:

when you declare a variable, it exists in the scope it was declared

#

you could declare the variable outside of the if, then assign it in the if

#

once you've solved that, can move onto the next layer (which is what others are talking about)