|
Okiphia Rayna
DemonEye Benefactor
Join date: 22 Sep 2007
Posts: 2,103
|
12-13-2007 09:12
I've been trying to figure it out from the wiki, but not really been able to.. so a question on if/else blocks ^_^ I found out yesterday that it's possible to do ifelse in a couple ways: if(condition) effect; else if(condition) effect; else(conditoin effect);
or if(condition) { effect; } else if(condition) { effect; } else { effect; }
But I can't figure out the difference. Is the method using the curly brackets just an easier way to organize or do they act differently? I did figure out that trying to do an ifelse call within an ifelse call is impossilbe without using the curly bracket method, as there's no way to differentiate the end...
_____________________
Owner of DemonEye Designs Custom Building and Landscaping Owner and Blogger, Okiphia's Life http://okiphiablog.blogspot.com/ 
|
|
Renee Roundfield
Registered User
Join date: 10 Mar 2006
Posts: 278
|
12-13-2007 09:27
You can contain multiple lines in a curly bracket.
|
|
Okiphia Rayna
DemonEye Benefactor
Join date: 22 Sep 2007
Posts: 2,103
|
12-13-2007 09:30
From: Renee Roundfield You can contain multiple lines in a curly bracket. Is that the only difference though? THey act the same, just brackets allow more per call?
_____________________
Owner of DemonEye Designs Custom Building and Landscaping Owner and Blogger, Okiphia's Life http://okiphiablog.blogspot.com/ 
|
|
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
|
12-13-2007 09:33
(pssst I think you mean "else if", not "if else" in your code)
Your two examples execute the same. Curly braces allow you to use multiple statements, and thus are more maintainable, so you will sometimes see people use them even if they only have one 'effect'.
Note that LSL is a little strange in having a rather low max number of cascaded if..else clauses, I believe it is 20? 24? I'd have to look it up.
_____________________
.  To contact forum folks, join the inworld group "The Forum Cartel". New residents with questions about SL more than welcome! We has parties!  To contact forum scripters, join the inworld group "Scriptoratti" (thanks Void!). New scripter questions welcome!
|
|
Okiphia Rayna
DemonEye Benefactor
Join date: 22 Sep 2007
Posts: 2,103
|
12-13-2007 09:35
From: Nika Talaj (pssst I think you mean "else if", not "if else" in your code)
Your two examples execute the same. Curly braces allow you to use multiple statements, and thus are more maintainable, so you will sometimes see people use them even if they only have one 'effect'.
Note that LSL is a little strange in having a rather low max number of cascaded if..else clauses, I believe it is 20? 24? I'd have to look it up. yeah lol...either way its understandable =P And thankies much ^_^
_____________________
Owner of DemonEye Designs Custom Building and Landscaping Owner and Blogger, Okiphia's Life http://okiphiablog.blogspot.com/ 
|
|
Bobbyb30 Zohari
SL Mentor Coach
Join date: 11 Nov 2006
Posts: 466
|
12-13-2007 09:43
From: Okiphia Rayna yeah lol...either way its understandable =P And thankies much ^_^ If you still need help, IM me in game.
|