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.

Ruby 101 && Coding Dojo

https://github.com/guiocavalcanti/ruby-101-dev-day

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to comment

  • Be the first to like this

Ruby 101 && Coding Dojo

  1. 1. Ruby 101Redu-dev team
  2. 2. Ruby 101• A dynamic, object oriented (really) open source programming language with a focus on simplicity and productivity.
  3. 3. irb• Stands for interactive ruby• For pythonists it’s an common concept• For Java programmers is like a bash session within the interpreter
  4. 4. Dynamically typed• Types are bound to values not to variables 1 my_var = "string" 2 my_var = 12
  5. 5. Everything is an object• Really 1 20.to_s # "20" 2 3 100.times do 4 puts "100 is an object" 5 end 6 # "100 is an object", "100 is an object"
  6. 6. Dynamic language• Some actions happens at runtime 9 class Person10 def say_hello 21 p = Person.new11 "hello" 22 p.say_hello12 end 23 # hello13 end 24 p.say_goodye14 25 # goodbye15 class Person16 def say_goodye17 "goodbye"18 end19 end
  7. 7. Methods 8 def my_method(arg, arg2="default") 9 "always returning the last line"10 end
  8. 8. Control structures30 if a > b 40 result = if a > b31 "a is greater than b" 41 "a is greater than b"32 else 42 else33 "a isnt greater than b" 43 "a isnt greater than b"34 end 44 end
  9. 9. Hashes• For pythonists: dictionaries• For Java programmers: associative arrays46 concepts = { "ruby" => "programming", "learning" =>"education" }47 concepts["ruby"]
  10. 10. Symbols• A symbol is something that you use to represent names. What this boils down to is a way to efficiently have descriptive names while saving the space one would use to generate a string for each naming instance.
  11. 11. 49 concepts = { :ruby => "programming", :learning=> "education" }
  12. 12. Blocks/Procs• Way to pass around chunks of code 51 def new_method(arg="default", &block) 52 puts "the arg is: #{arg}" 53 block.call 54 end 55 56 new_method do 57 puts "Callback" 58 end 59 60 # the arg is: default 61 # Callback
  13. 13. Symbols• Usually used as hashes keys
  14. 14. Dojo• With TDD (Test driven development)• A non-sense problem to be solved collaboratively• Tools • RSpec • Bundler • RVM

×