Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Programming With Ruby Episode 9, Flow Control Part 2

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
2,608
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jul 6, 2009

Now you learn how to create non-linear programs with if statements and loops

Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4222118

Original Post and Transcript: http://manwithcode.com/149/programming-with-ruby-episode-9-flow-control/

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (manwithcode)

  • This is a beautiful series. I have spent many hours reading until my eyes bulged. But I have learned more in one day watching your videos than I did in a week of pouring over docs. Thank you Tyler, I hope to see the saga continue!

  • @Liquillacole Thanks for your kind words :)

see all

All Comments (12)

Sign In or Sign Up now to post a comment!
  • @Jaredplusrandomstuff Oh! That one works! Cool! Thanks for sharing this, I guess there's always more I can learn :)

  • @Jaredplusrandomstuff line formatting doesn't show up too well but you get the idea :)

  • @manwithcode I mis-spoke, the correct syntax for 'or' in a case/when statement is the following:

    when '3', 'quit' puts "Goodbye!" input = 'quit'

    else .....

  • @Jaredplusrandomstuff That would be cleaner! Except when I try to run it, it doesn't work... And I've never seen that syntax for a when statement, but I know there are always things I don't know, so it's certainly possible I just inputted it wrong. The odd thing though is that your when statement *does* work when input is "3", which is consistent with my knowledge of Ruby expressions, since "3" or "quit" evaluates to "3", and would only ever evaluate to "quit" if "3" magically turned into a nil

  • @manwithcode I think the cleanest way would be to do this, which matches your menu prompt and also demonstrates a simple conditional in a case.

    when ('3' or 'quit') then

  • the videos are awesome

    they helped a LOT 

    thank you : D

  • i think it's worth noting that the else statement needs to go last or there will be syntax errors.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more