BINARY_SUBTRACT, huh, guess what that does. i still fear
whitespaceif (blah) {
stuff
}
if (blah)
{
stuff
}
(define (best-lang-in-list? seq)
(cond ((null? seq) #f)
((string=? (car seq) "scheme") #t)
(else (best-lang-in-list? (cdr seq)))))
if (name == "Deathalicious"):
‧‧‧‧‧‧‧‧print "You are awesome."
‧‧‧‧‧‧‧‧if time_of_day == "Noon":
‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧print "Lunch is on me!"
‧‧‧‧‧‧‧‧if time_of_day == "Evening":
‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧offer_copious_booze()
‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧throw_party()
‧‧‧‧‧‧‧‧give_candybar()
‧‧‧‧‧‧‧‧play_triumphant_music()
‧‧‧‧‧‧‧‧parade()
else:
‧‧‧‧‧‧‧‧print "Whatever"
Pretty neat, huh? Every time, I get candy, music, and a parade.
if (name == "Crabby Appleton"):
‧‧‧‧print "You are really nifty!"
‧‧‧‧if time_of_day == "Morning":
‧‧‧‧‧‧‧‧if day_of_week == "Monday":
‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧print "Take the week off!"
[snip]
‧‧‧‧‧‧‧‧if day_of_week == "Sunday"
‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧print "No chores for you!"
else:
‧‧‧‧print "Whatever"
You read my code and say, Wow. Candy, music, and a parade sounds awesome. I'm totally going to add that as something that happens each time.Here's what the code looks like if you do a straight cut-and-paste from my code to your code:
if (name == "Crabby Appleton"):
‧‧‧‧print "You are really nifty!"
‧‧‧‧if time_of_day == "Morning":
‧‧‧‧‧‧‧‧if day_of_week == "Monday":
‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧print "Take the week off!"
[snip]
‧‧‧‧‧‧‧‧if day_of_week == "Sunday"
‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧print "No chores for you!"
‧‧‧‧‧‧‧‧give_candybar()
‧‧‧‧‧‧‧‧play_triumphant_music()
‧‧‧‧‧‧‧‧parade()
else:
‧‧‧‧print "Whatever"
Oh noes! Unless you remove all that extra indentation, you only get the candy, parade, and music in the mornings! That isn't what you wanted at all. Now let's look at what the code looks like if we used tabs (indicated by -⇥):
if (name == "Deathalicious"):
-⇥print "You are awesome."
-⇥if time_of_day == "Noon":
-⇥-⇥print "Lunch is on me!"
-⇥if time_of_day == "Evening":
-⇥-⇥offer_copious_booze()
-⇥-⇥throw_party()
-⇥give_candybar()
-⇥play_triumphant_music()
-⇥parade()
else:
-⇥print "Whatever"
Your code:
if (name == "Crabby Appleton"):
-⇥print "You are really nifty!"
-⇥if time_of_day == "Morning":
-⇥-⇥if day_of_week == "Monday":
-⇥-⇥-⇥-⇥print "Take the week off!"
-⇥-⇥-⇥[snip]
-⇥-⇥if day_of_week == "Sunday"
-⇥-⇥-⇥-⇥print "No chores for you!"
else:
-⇥print "Whatever"
And here's your code with my code added:
if (name == "Crabby Appleton"):
-⇥print "You are really nifty!"
-⇥if time_of_day == "Morning":
-⇥-⇥if day_of_week == "Monday":
-⇥-⇥-⇥-⇥print "Take the week off!"
-⇥-⇥-⇥[snip]
-⇥-⇥if day_of_week == "Sunday"
-⇥-⇥-⇥-⇥print "No chores for you!"
-⇥give_candybar()
-⇥play_triumphant_music()
-⇥parade()
else:
-⇥print "Whatever"
Yay! That's exactly what you wanted!What happens if my indention amount is different from your indention amount?and the answer is: Nothing. Nothing happens if your indentation amount is different than mine. The only time -- really, the only time that indentation becomes a problem is when you use spaces. The only other exception, which as far as I know won't cause problems with how the code runs, but may make it look weird depending on indentation, is if you use extra tabs to make a line of text line up with a arbitrary position in the line above, as in:
pretty_little_array = [
"isn't",
"this",
"precious"
] which should always be replaced with normal_array = [
"no",
"it",
"isn't"
]« Older Steam, the hugely popular online videogame distrib... | Home Depot was having an issue... Newer »
This thread has been archived and is closed to new comments
posted by Mach5 at 1:23 PM on May 12, 2010