38
votes
\$\begingroup\$

Write a script that works fine when a blank line is present in the flow of program logic, but breaks or causes unexpected behaviour when that line is removed.

Avoid standard loopholes and stupid answers. Your program should do something "useful," even if all it does is add a few integers.

Removing an empty line from a multiline string doesn't count, unless the expected output from that multiline string shouldn't technically change (ie: if you're removing all blank lines matching ^$).

Whitespace foolery isn't allowed either; don't do weird things with carriage returns, tabs, spaces, etc.

\$\endgroup\$

closed as off-topic by cat, Mego, Blue, Martin Ender Apr 18 '16 at 14:51

  • This question does not appear to be about programming puzzles or code golf within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

locked by Martin Ender Apr 18 '16 at 14:51

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. See the help center for guidance on writing a good question.

Read more about locked posts here.

  • 11
    \$\begingroup\$ I think you should exclude Whitespace. \$\endgroup\$ – nneonneo Jun 12 '14 at 18:40
  • 17
    \$\begingroup\$ I think that Whitespace is a "standard loophole" \$\endgroup\$ – core1024 Jun 12 '14 at 18:42
  • 5
    \$\begingroup\$ nneonneo is talking about Whitespace, which is a language that uses only spaces as its syntax. \$\endgroup\$ – Kyle Kanos Jun 12 '14 at 18:48
  • 4
    \$\begingroup\$ "unexpected functionality" is a very good phrase. \$\endgroup\$ – Kaz Jun 13 '14 at 19:16
  • 3
    \$\begingroup\$ I'm voting to close this question as off-topic because underhanded challenges are no longer on-topic on this site. meta.codegolf.stackexchange.com/a/8326/20469 \$\endgroup\$ – cat Apr 18 '16 at 2:28

32 Answers 32

0
votes
\$\begingroup\$

AppleScript

say¬

quit

This code is absolutely meant to throw an error, as it matches (in compiler speak) to this:

¬
   say
quit

Which throws the error "Can’t make current application into type text."

However, if you delete the second line, you get the equivalent of this code:

say ¬
   (quit)

Which says nothing and attempts to close the current application (Script Editor or Terminal).

\$\endgroup\$
0
votes
\$\begingroup\$

><>

This program

02.

v"?"o
;"!"o

outputs

?

and exits.

Removing the blank line cause it to output

!
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.