This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question 6. What does the following print? | |
module A | |
def horses | |
puts "Called in Module A" | |
end | |
end | |
module B | |
include A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question 5. What's the output of the following? | |
def lambdicate | |
print "A" | |
lambda { return }.call | |
print "B" | |
end | |
def proctify | |
print "A" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question 4. What does the following print | |
p [:a, :b][2,1] | |
p [:a, :b][3,1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question 3. What does the following print? | |
p [String === "String", "String" === String] | |
p ["String".equal?("String"), "String".eql?("String"), "String" == "String"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question 17. What does the following print? | |
p 10.step(100, 20).to_a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question 16. What does the following print? | |
enum = ("branch"..."orbital socket").to_enum | |
p enum.next | |
p enum.next | |
p enum.next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question 14. What are the values of a, b, c and d? | |
a, (b, c), d = 1, 2, 3, 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question 13. What are the values of a and b? | |
*a, b = [1, 2, 3, 4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 11. What does the following evaluate to (as of Ruby 1.9)? | |
__method__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 10. What does the following evaluate to? | |
__FILE__ |