Computer Science Canada [tutorial] Case |
Author: | Clayton [ Wed Jan 25, 2006 3:50 pm ] | ||||
Post subject: | [tutorial] Case | ||||
a case is basically another form of an if. it takes a variable that youve gotten it and compares it to a set of possibilities for it to match ex.
in this way we can save enormous amounts of type and time typing out our conditions in our if statements. however, in a case , it only compares for something to be equal to it, so if you are having an if for say sorting, you cannot use an if because sorting usually needs to know > or < and as stated, you can only compare for equal to. for strings it is the same thing
so as you can see there is no difference in comparing strings and comparing integers other than the fact when comparing strings you need quotes around your conditions. that concludes my tutorial on cases. feel free to correct me if i am somehow wrong, i will take no offence hope it helps |
Author: | person [ Wed Jan 25, 2006 5:32 pm ] |
Post subject: | |
1) there is no colon after "of" 2) please indent ps: for a char format, u need single quotes just in case someone tries a char and it doesnt work with double quotes |
Author: | Clayton [ Thu Jan 26, 2006 12:19 am ] |
Post subject: | |
srry bout the colon and yes your right it is single quote thnx |
Author: | kanri [ Fri Jun 02, 2006 6:49 pm ] |
Post subject: | |
that was really really helpful thank you!! ![]() ![]() |