What is the difference between a proc, block, and lambda?
Resources Understanding blocks procs and lambdas
What is the difference between a proc, block, and lambda?
Resources Understanding blocks procs and lambdas
What is a closure?
How do we implement/create/use a closure in Ruby?
What's the difference between a closure in JS vs Ruby?
Why do we use closures so much more in JS as opposed to Ruby?
What is the Ruby analog of an anonymous function in Javascript?
what is a linked list?
how is a linked list different than an array?
why have you never heard of a linked list before?
how would you implement a linked list in ruby?
Walk through the flow of a request through Rails.
resources chrome networking stack
def flatten(array) | |
container = [] | |
array.each do |element| | |
if element.is_a?(Array) | |
sub = flatten(element) | |
container += sub | |
else | |
container += [element] | |
end | |
end |
Collections Practice | |
1. sort the following array in ascending order | |
["blake", "ashley", "scott"] | |
2. sort the following array in descending order | |
["blake", "ashley", "scott"] | |
3. put the following array in reverse order | |
["blake", "ashley", "scott"] | |
4. grab the second element in the array | |
["blake", "ashley", "scott"] |
pigeon_data = { | |
:color => { | |
:purple => ["Theo", "Peter Jr.", "Lucky"], | |
:grey => ["Theo", "Peter Jr.", "Ms .K"], | |
:white => ["Queenie", "Andrew", "Ms .K", "Alex"], | |
:brown => ["Queenie", "Alex"] | |
}, | |
:gender => { | |
:male => ["Alex", "Theo", "Peter Jr.", "Andrew", "Lucky"], | |
:female => ["Queenie", "Ms .K"] |
def first_even(items) | |
#code goes here | |
end |
Organizing Nested Data | |
I have a collection of Programming Languages. | |
languages = { | |
:oo => { | |
:ruby => { | |
:type => "interpreted" | |
}, | |
:javascript => { | |
:type => "interpreted" |
########### | |
# # | |
# ##### # # | |
# # # | |
### # ### # | |
# # # | |
# # ### ### | |
# # # | |
# ### # # # | |
# # # |