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

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-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?

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