MasterTobi Posted February 10, 2010 Share Posted February 10, 2010 hey hey in c++ or delphi , i can write switch(variable) { case 1: blalbla;exit case 2: blalbla;exit case 3: blalbla;exit ..... } it gives such a thing also in lua ? Link to comment
50p Posted February 10, 2010 Share Posted February 10, 2010 There is no switch in Lua. You have to use if, elseif and else statements instead. Link to comment
robhol Posted February 10, 2010 Share Posted February 10, 2010 Technically, you can also assign anonymous functions to a table and call it with your "switch" value as an index. However, depending on how many possibilities there are, you may be better off with simple if/elseif/else constructs as 50p says. if there are only 4-5 possibilities, a table with functions would be kinda overkill. Link to comment
MasterTobi Posted February 10, 2010 Author Share Posted February 10, 2010 ah ok spezial thx then i use if elseif Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now