Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Ruby is so fucking cool as fuck

Name: Anonymous 2011-08-20 8:21

So I was working on some LOL JAVA earlier (blackberry app) and basically I have a set of background images for different size blackberries, and load the appropriate run at runtime based on the Display.getWidth and getHeight

But also i do some set up of button sizes etc also.

Then I thought would it be cool if I could do a switch on an array

eg switch [width,height]

Now I haven;t tried it in Java, but I thought I bet ruby will do it, and blow me it does:


#!/usr/bin/env ruby

case [ARGV[0],ARGV[1]]
    when ["foo","bar"]
        puts "fooooooo baaaaar"
    when ["hello","world"]
        puts "helllloooo wooooorld"
    else
        puts "hmmmmmm"
end

Name: Anonymous 2011-08-20 8:43

Welcome to pattern matching, fag.

Name: Anonymous 2011-08-20 8:56

RUBY ON SNAILS EXPERT

Name: Anonymous 2011-08-20 10:25

I give it a non-sage bump.
Cause this code is almost
   as whorish as me.

Name: Anonymous 2011-08-20 10:44

See >>2 and go back to reddit.

Name: Anonymous 2011-08-20 11:55

okay you've had your fun with ruby. now use python like a real programmer

Name: Anonymous 2011-08-20 19:31

>>4
I need Cliff notes for this. I do.

Name: Anonymous 2011-08-21 2:16

Some people, when confronted with another lonely, soulless evening alone, think ``I know, I'll go on /prog/.'' Now they have countless problems.

Name: Anonymous 2011-08-21 18:31

Wouldn't it just be easier to use a switch inside each case since each first value will probably branch out to a different set of second values?

If it doesn't, then there will probably be so little choices that putting a few if statements before or after the switch will work fine.

If it doesn't branch at all then why are you using a multiway branch in the first place?

Name: Anonymous 2011-08-22 11:29

>>9
Because you touch yourself

Name: Anonymous 2011-08-22 11:37

Ruby is slow as fuck

Name: Anonymous 2011-08-22 11:57

I bet you must think you're cool because you can LOL on dat der intranet.

Don't change these.
Name: Email:
Entire Thread Thread List