Testing if a variable equals a line break

[code]testroom is a room.

gumby is initially “[line break]”.

When play begins:
if gumby is “[line break]”:
say “success!”;
say “failure.”[/code]
This test gives failure, though I’d hope for success.

Is there a way I can test if gumby equals a single line break, as it does?

I’m printing gumby directly to space things. It could contain anything from nothing at all to a bunch of text on separate lines, but I’m particularly interested in being able to test if it happens to contain just a line break, or just a paragraph break.


This seems to work. Check out §20.5 of the manual.

testroom is a room.

gumby is initially "[line break]".

When play begins:
	if gumby exactly matches the text "[line break]":
		say "success!";
		say "failure."

From what I can tell, “is” tests whether two things reference the same internal object rather than whether they merely have the same value (cf. the difference between the various equality predicates in lisp).

I’m usually good at thinking of variations that might work, then discovering they don’t, but to my chagrin I didn’t think of that one. And it worked. I don’t know anything about lisp, but thanks.


No. That used to be true, but now Inform attempts to compare the substituted forms of the texts. But it looks like there’s a bug when both texts contain substitutions.

I filed a bug on that. Funny that it’s never come up before.