This lesson gets more into the topics you may have been shaky on before like Control Flow, Looping, Arrays, Hashes, Blocks, Sorting. It's definitely got some more meat to it than the previous one. The projects in the Assignment section are good for doing on your own because Codecademy gives you all kinds of help with them.
Look through these now and then use them to test yourself after doing the assignment
Note: This is again a long list of things to understand! Read through the list, breathe deep, do the assignment, and then come back to them.
-
Conditionals and Flow Control
- What is a "boolean"?
- What are "truthy" values?
- Are
nil
,0
,"0"
,""
,1
,[]
,{}
and-1
considered true or false? - When do you use
elsif
? - When do you use
unless
? - What does
<=>
do? - Why might you define your own
<=>
method? - What do
||
and&&
and!
do? - What is returned by
puts("woah") || true
? - What is
||=
? - What is the ternary operator?
- When should you use a
case
statement?
-
Iteration
- What does
loop
do? - What are the two ways to denote a block of code?
- What is an index variable?
- How do you print out each item of a simple array
[1,3,5,7]
with:loop
?while
?for
?#each
?#times
?
- What's the difference between
while
anduntil
? - How do you stop a loop?
- How to you skip to the next iteration of a loop?
- How would you start the loop over again?
- What are the (basic) differences between situations when you would use
while
vs#times
vs#each
? - What does nesting loops mean and when would you use it?
- What does
-
Blocks, Procs, and Lambdas:
- How is a block like a function?
- How is a block different from a function?
- What are the two ways to declare a block?
- How do you return data from a block?
- What happens if you include a
return
statement in a block? - Why would you use a block instead of just creating a method?
- What does
yield
do? - How do you pass arguments to a block from within a method?
- How do you check whether a block was actually passed in?
- What is a proc?
- What's the difference between a proc and a block?
- When would you use a proc instead of a block?
- What is a closure?
- What is a lambda?
- What's different between a lambda and a proc?
- What is a Method (capital "M")?
- What do Methods basically allow you to do that could probably be pretty interesting when you're writing some more advanced programs later on?
-
Enumerable and Modules
- What is a module?
- Why are modules useful?
- What does
#each
do? - What does
#each
return? - What does
#map
do? - What does
#map
return? - What is the difference between
#map
and#collect
? - What does
#select
do? - What does
#select
return? - What is the difference between
#each
#map
and#select
? - What does
#inject
do? - When might you use
#inject
? - How do you check if every item in a hash fulfills a certain criteria?
- What about if none of the elements fulfill that criteria?
- What (basically) is an
enumerator
?
-
Writing Methods
- How many things should a method ideally do?
- What types of things should a method modify?
- What should you name a method?
- What does
self
mean? - What do you need to do to create your own Ruby script file?
- How would you run a Ruby script from the command line?
- How can you check whether your script was being run from the command line?
- What is a shebang line?
- What does
require
do? - What does
load
do? - What is the difference between
require
andload
? - How do you access any parameters that were passed to your script file from the command line?
- What does
#send
do? - When would
#send
be used that's different from just running the method on an object 'normally'?
-
Do the Codecademy Ruby sections 2-6, including:
-
Finish Beginning Ruby Chapter 3:
Ruby's Building Blocks: Data, Expressions, and Flow Control
(pages 50-76) -
For a look at underserved concepts and help with the questions above, check out these posts by Erik Trautman:
Make sure you can do the following quizzes from Code Quizzes. They're pretty quick and should give you an idea of what you still need to brush up on.
This section contains helpful links to other content. It isn't required, so consider it supplemental for if you need to dive deeper into something
- Still unsure about Enumerable? Check out the Enumerable Chapter of the Bastard's Book
- Github Gist on Truthiness
- See these answers on the Spaceship Operator
- Read Zetcode's Flow Control section for more depth on flow control.
- If you want a bit more, check out Skork's entry on Ruby looping and iterators
- Understanding Blocks Procs and Lambdas
- Why can you either
yield
to blocks or make them explicit? Who cares? (from SO) - Writing your Own Methods
- A quick guide on writing methods from wikibooks
- Getting to Hello World
- LRTHW chapters 13-14