someguy567 Posted August 30, 2018 Posted August 30, 2018 I know scripts will need to use lots of if statements. However, if I use too many will that be a bad thing in terms of script performance or won't it matter much for the script at all? And if it does matter, are there alternatives to using if statements which I could implement instead?
Charlotte Posted August 30, 2018 Posted August 30, 2018 I think too many if statements does not really affect performance if they get executed. Alternative would be switch-case.
Nintendo Switch Posted August 30, 2018 Posted August 30, 2018 1 minute ago, Charlotte said: I think too many if statements does not really affect performance if they get executed. Alternative would be switch-case. yeah as charlotte said, use switch statements which will ahve cases - if ur switch matches the case it will then return xy or whatever ur case was.
FrostBug Posted August 30, 2018 Posted August 30, 2018 Use as many if statements as you need. But if you find yourself with a series of 10+ if/else statements, then it could probably have been implemented in a better way.
fhhhphgj Posted August 30, 2018 Posted August 30, 2018 Don't worry it won't affect the performance. Short answer; yes. If you are creating a more complex script you can make us of polymorphism, referenced assignments and branches.