Jump to content

If statement is unreachable?


Recommended Posts

Posted

Can anyone tell me why this statement is unreachable? If I mess around with the brackets to get the statement reachable, the else statement isn't paired with any if statements anymore. Its on line 43

https://gyazo.com/c840ffe12d80c78008ce9c1f6f1cc31c

And if anyone could give me feedback or pointers for the code I have right now, that would be really appreciated. 

https://github.com/Dab-in-a-Lab/Wilderness-Looter/blob/master/Current Code

Posted
14 minutes ago, Theorems said:

Looks a bit messy... Are you declaring a method in your onLoop()? also you have a return statement right after you declare the method so all the code that follows in unreachable. Also what's with the random curly brackets on line 41? that could also be causing issues.

Hahaha ya, I quickly realized I was a little too ambitious with this script. Only just started learning how to code this week, and the project seemed easy enough until I actually got a bit further into it ?

I fixed the return statement and I honestly don't know why the curly bracket was there, I think it was attached to the end of line 40?

It seems to be working for now, thank you.

  • Like 1
Posted
22 minutes ago, Dab in a Lab said:

Hahaha ya, I quickly realized I was a little too ambitious with this script. Only just started learning how to code this week, and the project seemed easy enough until I actually got a bit further into it ?

I fixed the return statement and I honestly don't know why the curly bracket was there, I think it was attached to the end of line 40?

It seems to be working for now, thank you.

Good luck with the script! you're doing really well for someone who is just learning

  • Heart 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...