Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to ruby


Published on

  • Be the first to comment

  • Be the first to like this

Introduction to ruby

  1. 1. Introduction to Ruby Andrew Liu
  2. 2. Ruby is…• Designed by Yukihiro Matsumoto (松本行弘) – "I wanted a scripting language that was more powerful than Perl, and more object- oriented than Python. Thats why I decided to design my own language“• An object-oriented scripting language• Easy to learn!
  3. 3. Philosophy• Often people, especially computer engineers, focus on the machines. They think, "By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, the machine will something something something."• They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.
  4. 4. Naming Convention• CamelCase – Class names, module names• ALLCAPITAL – Constants• words_with_underscore – Method names, variable names• $ prefix – Global variables
  5. 5. Everything is an object!
  6. 6. Strings
  7. 7. String Methods
  8. 8. Array
  9. 9. What if I want to reverse the array?
  10. 10. Range
  11. 11. Hash
  12. 12. Block
  13. 13. How does it work?
  14. 14. More About Class
  15. 15. More About Class
  16. 16. Class• Variable – @@ prefix: Shared by all class instances – @ prefix: Contains instances information – No prefix: normal variables• Methods – self. Prefix: Class methods, as known as static method – No prefix: Instance methods, must be called with a instance
  17. 17. Creating Instance
  18. 18. Flow Control
  19. 19. Cases
  20. 20. While
  21. 21. For
  22. 22. Resources• Programming Ruby (Bible) – http://www.ruby-• Ruby API Document –• TryRuby –• Ruby Warrior –