Thank you for the tutorial! I love interactive ones...They make everything easier c:
Though, I'm in the first lesson, and I must say that 'master' is quite coldhearted ;-; (No pizza for me...)
I don't get it...Can I ask some questions?
1. (lesson 1) when you're specifying what object are you with the code 'self', just what exactly are the possibilities of objects you can be? What are exactly the 'objects'?
At first I put "character self" --> no good
Then "vase self" (Yes, I wrote that) --> no good
And then I put a number (1), At least it wasn't that bad, but "the master said": 'that's not the code I was looking for e-e
2. (lesson 2) Just like in lesson 1, what are the 'methods'? can you name an example?
Sorry for the lots of question ;-;
When working through that particular website, it's essential to understand that the descriptions and guides are very, very literal. So, for the first lesson, the correct code is simply 'self' (i you're lost, some of the lessons automatically put the code in the box for you, so all you have to do is hit the 'run' button to see what happens). You'll further understand what 'self' means as you progress through the lessons, but basically, you're saying this: "there's one object in this entire script, and I'm that object", hence 'main' appears. 'Self' doesn't define the object as a physical, recognizable object; all you're doing is clarifying that there
is an object in the script. You'll learn how to define what those objects are later on. It's also important to understand that individual
numbers are objects in of themselves.
At its core, Ruby consists of objects and methods. To answer your question about lesson 2, the correct code is '2.even?' (this particular lesson automatically puts the code in the box for you). If you're still confused, let's look at it this way: let's say that you're standing in a completely empty room. You spout the word '2', and lo and behold, a giant number '2' appears (the code for this would simply be '2').
As you look at the number 2, you realize that you want to know more about it. You walk over to the number 2 and ask "are you an even number?" to which '2' replies "yes, that's true." The code for this conversation would look like this: '
2.even?' - The '2' represents the object, the period indicates that you're having a conversation with the '2', and whatever you want to say to the '2' follows the period. In this case, the method 'even?' follows the period, meaning that we're asking the '2' if it's an even number or not.
'
2.even?' = "Hey, number 2, are you an even number?"
Learning Ruby will take a lot of time and patience. You'll want to throw your computer across the room at times, but that's just part of the learning process. I suggest that you read everything you can about Ruby (basic programming, even); make sure you understand what's happening when you work through the lessons on RubyMonk. If you get to a lesson that you don't understand, that's completely normal, so keep working at it! If you apply yourself, you'll be surprised at how how much you've learned at the end of every week. It just takes a hell of a lot of
patience.
I hope this helps!