!Spoiler Warning! If you haven’t completed the Ruby Basics Project of Web Dev 101 yet, you may not want to read this.
I just completed the sixth task of the Ruby Basics Project (05_book_titles) and even though I did know what I had to do (as it was similar to the Simon Says task), I had no idea, what the test wanted, so I looked at the solution.
The problem I had was, that two functions had to be specified - title and title=. Coming from Python, it seems really weird to define a function called title= and invoking it with "@book.title = ‘something’ ".
Is defining a function with an equal sign at the end of a functions name a convention in Ruby?
Why not let the Book-Class take a title-argument and invoking the titleize-function in the initialize-function of the Class?
Maybe I missed this part during the tutorials, but I can’t remember learning about the possibility of creating such a function. I really like this principle, but not knowing about that made the task a little hard for me, even though I knew how to solve the problem.
Edit: I looked through the tutorials again and I didn’t find an explanation, that such a function is possible. Maybe you want to explain this at one point (I’d prefer this) or change the spec-file to not include such a beginner-weird way to define a function. (Or am I the only one/one of a few who had this problem? I don’t want to exclude the possibility, that I was the problem )