Skip to content

Instantly share code, notes, and snippets.

@rafer
rafer / gist:920427
Created April 14, 2011 20:26
ROB 4/14/2011 Trivia: Question 6
# Question 6. What does the following print?
module A
def horses
puts "Called in Module A"
end
end
module B
include A
@rafer
rafer / gist:920423
Created April 14, 2011 20:25
ROB 4/14/2011 Trivia: Question 5
# Question 5. What's the output of the following?
def lambdicate
print "A"
lambda { return }.call
print "B"
end
def proctify
print "A"
@rafer
rafer / gist:920414
Created April 14, 2011 20:24
ROB 4/14/2011 Trivia: Question 4
# Question 4. What does the following print
p [:a, :b][2,1]
p [:a, :b][3,1]
@rafer
rafer / gist:920410
Created April 14, 2011 20:23
ROB 4/14/2011 Trivia: Question 3
# Question 3. What does the following print?
p [String === "String", "String" === String]
p ["String".equal?("String"), "String".eql?("String"), "String" == "String"]
@rafer
rafer / question_17.rb
Created April 14, 2011 20:40
ROB 4/14/2011 Trivia: Question 17
# Question 17. What does the following print?
p 10.step(100, 20).to_a
@rafer
rafer / question_16.rb
Created April 14, 2011 20:39
ROB 4/14/2011 Trivia: Question 16
# Question 16. What does the following print?
enum = ("branch"..."orbital socket").to_enum
p enum.next
p enum.next
p enum.next
@rafer
rafer / question_14.rb
Created April 14, 2011 20:37
ROB 4/14/2011 Trivia: Question 14
# Question 14. What are the values of a, b, c and d?
a, (b, c), d = 1, 2, 3, 4
@rafer
rafer / gist:920466
Created April 14, 2011 20:36
ROB 4/14/2011 Trivia: Question 13
# Question 13. What are the values of a and b?
*a, b = [1, 2, 3, 4]
@rafer
rafer / gist:920460
Created April 14, 2011 20:34
ROB 4/14/2011 Trivia: Question 11
# 11. What does the following evaluate to (as of Ruby 1.9)?
__method__
@rafer
rafer / gist:920458
Created April 14, 2011 20:34
ROB 4/14/2011 Trivia: Question 10
# 10. What does the following evaluate to?
__FILE__