This file contains hidden or 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 hidden or 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 7. | |
# What happens when you run the following? | |
p x | |
# And what happens when you run the following? | |
x = 5 if false | |
p x |
This file contains hidden or 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
#8. What instance method is defined on Symbol in active_support/ruby 1.9.2 to enable the ampersand trick? | |
# For example: | |
[1].map(&:to_s) # => ["1"] |
This file contains hidden or 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 9. What does the "def" look like for prefixed unary operators as in: | |
trinsty = Crowndis.new | |
negative_trinsty = - trinsty |
This file contains hidden or 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__ |
This file contains hidden or 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 hidden or 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 12. What does the following print (as of Ruby 1.9)? | |
thang = "biscuits" | |
[1,2,3].each { |n; thang| thang = n } | |
puts thang |
This file contains hidden or 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 hidden or 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 hidden or 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 15. What are the values of a, b, c and d? | |
a, (b, *c), d = 1, [2, 3, 4], 5 |