Skip to content

Instantly share code, notes, and snippets.

Avatar

Wilfrido Nuqui Jr. wnuqui

View GitHub Profile
@wnuqui
wnuqui / gist:2666669
Created May 12, 2012
What is your quick guess for the 2nd line?
View gist:2666669
# send following line to irb and see the result
a = 1, b = 2*5
# perhaps this is better
a = 1, (b = 2*5)
@wnuqui
wnuqui / gist:2666644
Created May 12, 2012
safe conversions instead of to_x
View gist:2666644
i = "1i"
i.to_i # => 1
Integer(i) # => ArgumentError: invalid value for Integer(): "1i"
f = "1.2f"
f.to_f # => 1.2
Float(f) # => ArgumentError: invalid value for Float(): "1.2f"
@wnuqui
wnuqui / gist:2652404
Created May 10, 2012
Put your constant at the bottom
View gist:2652404
class A
def self.constant
[1, 2, 3]
end
B = constant and nil
end
View gist:2651356
class A
def b
data = [1, 2, 3]
def data.foo!
self.sample
end
data
end
end
You can’t perform that action at this time.