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\$
15
  • 11
    \$\begingroup\$ I think you should exclude Whitespace. \$\endgroup\$
    – nneonneo
    Jun 12, 2014 at 18:40
  • 17
    \$\begingroup\$ I think that Whitespace is a "standard loophole" \$\endgroup\$
    – core1024
    Jun 12, 2014 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, 2014 at 18:48
  • 4
    \$\begingroup\$ "unexpected functionality" is a very good phrase. \$\endgroup\$
    – Kaz
    Jun 13, 2014 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, 2016 at 2:28

32 Answers 32

1
2
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\$
1
2

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