Broken switch-Statement

I have problems with this snippet of code:

		switch (SettingsHandler.getSetting("language")) {
		case "de":
			languageSwitch.setState(1); // de
		case "en":
			languageSwitch.setState(0); // en
		}

As you can see, if the method getSetting() returns “de”, the object languageHandler’s setState() method get’s called and set to 0. But this doesn’t seem to work.
I printed the result of getSettings(“language”) and it is “de”. After the switch statement, I use getState() on languageSwitch and it returns 0 even though I just set it to 1!
Yes, this mostly are custom objects with custom methods but they seem to work alright. But if you need them, let me know what exactly!

Put a ‘break;’ in there


 switch (SettingsHandler.getSetting("language")) {
      case "de":
         languageSwitch.setState(1); // de
         break;
      case "en":
         languageSwitch.setState(0); // en
         break;
      }

Without a break between each case, all of the statements beneath the case without a break will also get called unless there is another break.

Thank you, sir! That worked!
I guess I didn’t come up with it myself because I had tried to replace the switch statement with if’s and they didn’t work either; probably because of me beeing stupid ::slight_smile: