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
def pretty_print(array_of_arrays) | |
array_of_arrays.each do |array| | |
puts "[#{array.join(",")}]" | |
end | |
end | |
def combinations_for_free(array_of_arrays) | |
array_of_arrays[0].product(*array_of_arrays[1...]) | |
end |
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
def no_ensure | |
:ok | |
end | |
def with_ensure | |
:ok | |
ensure | |
:ensure | |
end |
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
# To test yourself on the actual quiz, see | |
# https://www.vector-logic.com/blog/posts/test-yourself-on-ruby-array-operations | |
def print_question_number(n) | |
puts ["="*20, n, "="*20].join(" ") | |
end | |
# Array indexing options | |
print_question_number(1) | |
arr = ['a', 'b', 'c', 'd', 'e'] |
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
# To test yourself on the actual quiz, see | |
# https://www.vector-logic.com/blog/posts/test-yourself-on-ruby-object-model | |
puts "Question 1" | |
class First; end | |
f = First.new | |
puts f.class.superclass # Object | |
puts "\n\n" | |
puts "Question 2" |
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
# To test yourself on the actual quiz go to | |
# https://www.vector-logic.com/blog/posts/test-yourself-on-operator-precdence-in-ruby | |
a = false | |
b = true | |
c = 3 | |
d = 4 | |
expressions = [ | |
"1 + 2 * 2", # Outputs 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
#!/bin/sh | |
if git rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
fi |