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 17. What does the following print? | |
p 10.step(100, 20).to_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 16. What does the following print? | |
enum = ("branch"..."orbital socket").to_enum | |
p enum.next | |
p enum.next | |
p enum.next |
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 |
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 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 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
# 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
# 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
# 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
#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"] |