Out of all the exercises, I really enjoyed number 20. Although this is one of the more popular ones, I think this is the intention of Linda Liukas. Everyone can personalize each exercise to their liking.

seen from Malaysia
seen from China
seen from Russia
seen from China
seen from United Kingdom
seen from China
seen from China
seen from China
seen from United States
seen from China

seen from Slovakia

seen from United States
seen from Malaysia
seen from Australia

seen from Mexico
seen from China

seen from United States
seen from Germany
seen from United States

seen from United Kingdom
Out of all the exercises, I really enjoyed number 20. Although this is one of the more popular ones, I think this is the intention of Linda Liukas. Everyone can personalize each exercise to their liking.
I chose to do activity 15 in Hello Ruby. This was a Sudoku challenge using computer icons instead of numbers; it was really fun to match each bit up with its counterparts. Hello Ruby is a very unique book, in that it is covering a vast amount of avenues here. Gender roles in math and science, generational technology gaps, and the use of technology in young ages are just a few topics that can be discussed after reading this. The author’s TedTalk was inspirational in giving insight into why she decided to write this book and her genuineness for doing so.
I did exercise 19, because I felt that it was interesting to know what makes up the sizes of files and videos that we have on our computers. The picture above were my guesses and I got a couple wrong actually, which goes to show that knowing the biggest byte sizes could help me conserve my storage space. A holiday picture is actually 1 megabyte, and one kilobyte would be the equivalent to a paragraph of text, and a short video would be close to a gigabyte. These activities are a fun and diverse way to help readers learn more about coding through practical and easy examples, the author did an excellent job on portraying computers as a positive learning apparatus.
A great talk by Linda Liukas, author of the wonderful children's book Hello Ruby, on the mission of RailsGirls, and some of the unique perspectives that its teaching methods can bring to women trying to learn Rails. Worth a watch.
A delightful way to teach kids about computers | Linda Liukas
A delightful way to teach kids about computers | Linda Liukas
Computer code is the next universal language, and its syntax will be limited only by the imaginations of the next generation of programmers. Linda Liukas is helping to educate problem-solving kids, encouraging them to see computers not as mechanical, boring and complicated but as colorful, expressive machines meant to be tinkered…
View On WordPress
Linda Liukas - Hello Ruby
Dostałem właśnie wersję w PDF i jaram się jak dziecko! :-)
Ciekawe jak wyjdzie edycja drukowana, a wysyłka ma zacząć się już niebawem.
Zainteresowanych odsyłam do konichiwaruby po więcej info.
Linda Liukas believes the world will be a better place if more women learn computer coding, and has written a children’s book to catch them young
Cute ruby code
I recently funded the “Hello Ruby" programming book on Kickstarter to help teach my kids programming. I was asked if I want a personal message in a custom sketch. This is the message I requested:
%w[i love you].each{|m|eval "def #{m}(n=nil);\"#{m} \#\{n ?n :'too'\}\";end"}
Try it out in irb, and then type:
i love you
I hope my kids will like it. ☺
Explanation of the code
This code has a number of things going on with it. Let’s take some time to break the code down. First of all, let’s expend the code out to multiple lines, expand out the ternary operator to an if statement and give the variables sane (read: not one-letter) names:
%w[i love you].each do |method_name| eval <<-eos def #{method_name}(parameter = nil) second_word = if parameter != nil parameter else 'too' end "#{method_name} \#\{second_word\}" end eos end
Hopefully, that is a little clearer, but let’s break it down.
First off, what the heck does %w[i love you] do? Well, this is a shortcut for creating an array. So:
%w[i love you] == ['i', 'love', 'you']
Next up is the each statement. It will take whatever is inside the follow block and executes it for each string in the array [‘i’, ‘love’, ‘you’], passing in the string to the variable “method_name.” That means for each iteration “method_name" will equal something different:
method_name = 'i' # iteration 1 (first) method_name = 'love' # iteration 2 method_name = 'you' # iteration 3 (last)
Next up is the eval statement. In Ruby (and many other languages), the eval command takes a string and turns it into a code. Eval is short for evaluate. So the following string will be turned into actual code, but with the “method_name" variable interpreted:
def #{method_name}(parameter = nil) second_word = if parameter != nil parameter else 'too' end "#{method_name} \#\{second_word\}" end
The trickiest bit here is the escaped “\#\{second_word\}”. After this is evaluated it expands to “#{second_name}.” We need this because second_name is a local variable in the method, and needs to be interpreted when it is called, not when it is created.
Note: the «-eos … eos in the expanded code is a way in Ruby to create a multi-line string.
So this code will be evaluated three times, making three methods:
# iteration 1 (first) def i(parameter = nil) second_word = if parameter != nil parameter else 'too' end "i #{second_word}" end # iteration 2 def love(parameter = nil) second_word = if parameter != nil parameter else 'too' end "love #{second_word}" end # iteration 3 (last) def you(parameter = nil) second_word = if parameter != nil parameter else 'too' end "you #{second_word}" end
Next, you see that the parameter defaults to nil, and second_name is then assigned to the result of the following if block:
if parameter != nil parameter else 'too' end
This is the same as the following ternary operation that you can see in the one-liner:
parameter ?parameter :'too'
It says “if you passed in a parameter, set the second word to that, otherwise set the second parameter to the string ‘too.’”
The last line of all the methods simply returns the name of the method plus the second word, or ‘too’ if you pass nothing into it.
That means the following method calls produce the following strings:
you() == "you too"
and of course:
love("you too") == "love you too"
therefore:
love(you()) == "love you too"
and:
i("love you too") == "i love you too"
thus:
i(love(you())) == "i love you too"
But in Ruby, parentheses are optional making:
i(love(you())) == (i love you)
And that is why typing i love you in irb will produce the string “i love you too”
I hope you enjoyed my explanation. I enjoyed writing it.