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

Ruby is beautiful

Name: Anonymous 2009-08-26 15:25

class Cycle
    def cycle(*args)
      args[((@_cycles ||= Hash.new(-1))[args.hash] += 1) % args.size]
    end
end

More beautiful code plees?

Name: Anonymous 2012-01-27 22:40

>>94

indeed. it kind of sucks


function a(n) return if true then 1 else 2 end end
stdin:1: unexpected symbol near 'if'


oh no, wait:


function a(n)
>> local results = {[true] = 1, [false] = 54}
>> return results[n < 5]
>> end
print(a(3))
1
print(a(4))
1
print(a(5))
54
print(a(8))
54

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