# Ruby misfeature? =\> CONTEST: solve the following problem

**URL:** <https://rubytalk.org/t/ruby-misfeature-contest-solve-the-following-problem/5788>\
**Category:** ruby-talk\
**Created:** [26 April 2003 22:15 UTC](https://rubytalk.org/t/ruby-misfeature-contest-solve-the-following-problem/5788 "2003-04-26T22:15:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mauricio\_Fernndez](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@Mauricio\_Fernndez](https://rubytalk.org/u/Mauricio_Fernndez)\
**Post date:** [26 April 2003 22:15 UTC](https://rubytalk.org/t/ruby-misfeature-contest-solve-the-following-problem/5788/1 "2003-04-26T22:15:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ptkwt1](https://avatars.discourse-cdn.com/v4/letter/p/85e7bf/32.png) [@Ptkwt1](https://rubytalk.org/u/Ptkwt1)\
**Post date:** [27 April 2003 01:51 UTC](https://rubytalk.org/t/ruby-misfeature-contest-solve-the-following-problem/5788/2 "2003-04-27T01:51:29Z")

</div>

In article [20030426221505.GA7411@student.ei.uni-stuttgart.de](mailto:20030426221505.GA7411@student.ei.uni-stuttgart.de),

> **···**
>
> Mauricio Fernández [batsman.geo@yahoo.com](mailto: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

---

<div class="post-metadata">

**Author:** ![David\_A\_Black2](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@David\_A\_Black2](https://rubytalk.org/u/David_A_Black2)\
**Post date:** [27 April 2003 10:32 UTC](https://rubytalk.org/t/ruby-misfeature-contest-solve-the-following-problem/5788/3 "2003-04-27T10:32:27Z")

</div>

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?)
> 
> David
> 
> –  
> David Alan Black  
> home: [dblack@superlink.net](mailto:dblack@superlink.net)  
> work: blackdav@shu.edu  
> Web: [http://pirate.shu.edu/~blackdav](http://pirate.shu.edu/~blackdav)

---

<div class="post-metadata">

**Author:** ![Mauricio\_Fernndez](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@Mauricio\_Fernndez](https://rubytalk.org/u/Mauricio_Fernndez)\
**Post date:** [27 April 2003 06:07 UTC](https://rubytalk.org/t/ruby-misfeature-contest-solve-the-following-problem/5788/4 "2003-04-27T06:07:29Z")

</div>

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](https://rubytalk.org/uploads/short-url/3vsRKfyITk0izNx2rhwdAppmv0V.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

---

<div class="post-metadata">

**Author:** ![Mauricio\_Fernndez](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@Mauricio\_Fernndez](https://rubytalk.org/u/Mauricio_Fernndez)\
**Post date:** [27 April 2003 10:42 UTC](https://rubytalk.org/t/ruby-misfeature-contest-solve-the-following-problem/5788/5 "2003-04-27T10:42:15Z")

</div>

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](mailto: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
