What’s the output of the following script?
Points awarded only if you don’t run it
#raise “Gave up already?”
def with(*objs, &block)
objs.each { |o| o.instance_eval(&block) }
end
a = %
b = %
c = %
d = %
with a,b,c,d do
case self
when " "; puts “foo”
when “\t”; puts “bar”
when “\n”; puts “baz”
end
end
This feature has some serious potential for abuse! Good enough for an
almost indecipherable obfuscated Ruby program…
We shall now see who’s got the best MUA
···
–
_ _
__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_
_ \ / ` | ’ \
) | (| | |__ \ | | | | | (| | | | |
.__/ _,|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
A Linux machine! Because a 486 is a terrible thing to waste!
– Joe Sloan, jjs@wintermute.ucr.edu
In article 20030426221505.GA7411@student.ei.uni-stuttgart.de,
···
Mauricio Fernández batsman.geo@yahoo.com wrote:
What’s the output of the following script?
Points awarded only if you don’t run it
#raise “Gave up already?”
def with(*objs, &block)
objs.each { |o| o.instance_eval(&block) }
end
a = %
b = %
c = %
d = %
with a,b,c,d do
case self
when " "; puts “foo”
when “\t”; puts “bar”
when “\n”; puts “baz”
end
end
This feature has some serious potential for abuse! Good enough for an
almost indecipherable obfuscated Ruby program…
We shall now see who’s got the best MUA
OK, I’ll admit to cheating by running this script…
I didn’t see it print anything.
Phil
This happens if you select it and then try to copy/paste ‘à la X’; it
seems this somehow strips away spaces and/or tabs. When posting I tried
to simply copy the code w/ KClipboard and it kept swallowing significant
spaces.
I guess you’d have to extract the source code directly from the email, ie.
save it and then edit everything else away.
Or you might use the attached file
BTW, I’d expect this to behave differently on Windows because of the
CR/LF issue…
a.rb (247 Bytes)
···
On Sun, Apr 27, 2003 at 10:51:29AM +0900, Phil Tomson wrote:
OK, I’ll admit to cheating by running this script…
I didn’t see it print anything.
–
_ _
__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_
_ \ / ` | ’ \
) | (| | |__ \ | | | | | (| | | | |
.__/ _,|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
People disagree with me. I just ignore them.
– Linus Torvalds, regarding the use of C++ for the Linux kernel
The possible misfeature is allowing spaces as delimiters.
Can we expect anybody to tell the difference between
a = %
and
a = %
???
IMHO in the original posting
def expand(*args)
% args
end
should complain about the infix operator being used improperly or
something similar, instead of parsing “under the hood” as %{args}.
···
On Sun, Apr 27, 2003 at 07:32:27PM +0900, dblack@superlink.net wrote:
Hi –
On Sun, 27 Apr 2003, Mauricio [iso-8859-1] Fernández wrote:
What’s the output of the following script?
Points awarded only if you don’t run it
I get no points I ran the code, and got no output, but then I ran
the second version and it was fine.
I didn’t see any surprises in the output. I’m not sure what problem
or misfeature you’re pointing to. (Maybe the Windows compatibility
question?)
–
_ _
__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_
_ \ / ` | ’ \
) | (| | |__ \ | | | | | (| | | | |
.__/ _,|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
C is quirky, flawed, and an enormous success
– Dennis M. Ritchie