Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Operators and Control Structures Logical Operators The Or (||) Operator

kevinthecoder
kevinthecoder
10,791 Points

Can't figure out valid_command section.

Alright, that's two challenges in a row that I can't figure out now. I have a feeling that the define portion is throwing me off. I have attached my code. Any suggestions? I'm stumped.

ruby.rb
def valid_command?(command)
  command=gets.chomp.to_i
  if command=="y" || command=="Y" || command == "YES"
    valid_command?=true
end
Colin Marshall
Colin Marshall
32,861 Points

Did you look at our answers to your other question? You made some of the same mistakes in this one that you did in your other question. I could give you the answer to this one but I think you should give it another try first.

2 Answers

kevinthecoder
kevinthecoder
10,791 Points

Colin,

Yes, I replied in the other forum with a detailed answer. Let me try this again and see if I can do the challenge this time.

kevinthecoder
kevinthecoder
10,791 Points

OK, Colin, thanks!

So this one was easy for me and I got it the first time. However, let me tell you how I got it, though, so that you understand the way I was thinking. I saw that the question being asked didn't ask about a string this time (example: "safe"). Therefore, the only option, in my mind, was to do a return on the method name itself. So in my If statement, I simply did a return method name , and then closed it properly with 'end' (thanks for the tip!). My own issues are that I tend to be very anal and very detail-oriented and can get tunnel vision or that I am not able to interpret something correctly.

FYI: I do come from a technical background (not IT or web development) and am trying to completely change career paths to web development such as Ruby, Javascript etc; I'm not sure what angle yet, hence the reason to try different courses on teamtreehouse to see what sticks and to see if I can find a niche or something that I like. Getting someone locally and to work one-on-one with me is extremely hard to find (not to mention the cost) and I am still in the process of gathering the initial knowledge and finding local resources to work with and so on. A full blow school or college is not the way to go (at least not yet) as I need to dabble in a few different areas (i.e. Ruby, Javascript) and see what I like, front-end, back-end and so on.

Bottom line: this is a bit tough for me. Based on my own research, however, I made the conclusion that of the 3 or 4 online options to learn web development, I figured that teamtreehouse would be the best online, low-cost option that would explain it slowly to me and in such a manner where I could learn the basics correctly. So far, I think I made the right choice. If I were more advanced, I would guess that teamtreehouse would be a little too easy for me.

Hope this helps. Feel free to provide feedback (in this forum or privately if there is a way to contact me directly) if you see anything that I missed.

Thanks again! I am off to the next challenge in the same section....

Colin Marshall
Colin Marshall
32,861 Points

Glad you got the answer on your own! Good job!

Just like anything else in life, becoming a web developer will just take lots of time and practice. You're not going to get everything the first try. My suggestion to you would be to pick one language and get really good at it. All languages operate similarly and once you have one language down you can pick up another language and understand it quickly once you know the syntax.

As for the difficulty of the courses, Treehouse has courses for all levels. In my experience, if you want to learn web development you will need to learn from a variety of sources. So once you get through the Treehouse material, move on to learning from another source.