1172
submitted 2 years ago by [email protected] to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 66 points 2 years ago

“exit”

✈️: Use exit() or Ctrl-D (I.e. EOF) to exit

[-] [email protected] 15 points 2 years ago

I mean if they can see that we type exit and show us this message, why could they not just start the exiting when we type exit?

[-] [email protected] 19 points 2 years ago

Because exit might be a variable you use to determine if you should exit. exit() is a function that actually does the exiting.

It’s the difference between pointing at a jogger and saying “run” and actually running after them.

[-] [email protected] 17 points 2 years ago

If you have a variable called exit you've overwritten the function in that scope, and won't be able to execute it.

e.g.

>>> exit=1
>>> exit()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is not callable
>>>
[-] [email protected] 17 points 2 years ago

Reminds me of setting pi = 3 in my friends matlab subroutines in school.

[-] [email protected] 5 points 2 years ago

wow it does do that. cool

load more comments (8 replies)
load more comments (8 replies)
this post was submitted on 11 Dec 2023
1172 points (98.9% liked)

Programmer Humor

37164 readers
406 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS