Upgrade to Pro — share decks privately, control downloads, hide ads and more …

May the source be with you

高見龍
December 08, 2012

May the source be with you

Learn more about Ruby through reading Ruby source code.

高見龍

December 08, 2012
Tweet

More Decks by 高見龍

Other Decks in Programming

Transcript

  1. May the Source Be with You Chimpr Learning Ruby by

    Reading Ruby Source Code 12年12月8日星期六
  2. - why read source code? - how o sart? -

    anything ineresting? - wrie a simple Ruby Exension with C. 12年12月8日星期六
  3. "once you sart digging around in someone else’s code base,

    you’ll learn a lot about your own strengths and weaknesses" - Ruby Best Practice http://blog.rubybestpractices.com/posts/gregory/005-code-reading-stdlib.html 12年12月8日星期六
  4. get Ruby source code download from Ruby websie: http://www.ruby-lang.org/en/ or

    from github: https://github.com/ruby/ruby 12年12月8日星期六
  5. Object = RObject, Class = RClass, String = RString, Array

    = RArray, Hash = RHash, Basic = RBasic 12年12月8日星期六
  6. = rb_define_module_method on kernel = rb_define_private_method on kernel + rb_define_singleton_method

    on kernel class.c#1332 rb_define_global_function() 12年12月8日星期六
  7. class A def initialize puts "hello" end end a =

    A.new 12年12月8日星期六
  8. proc.c#2105 how to execute a Proc? - proc.call - proc[]

    - proc === 123 - proc.yield 12年12月8日星期六
  9. array.c#742 (push) static VALUE rb_ary_push_m(int argc, VALUE *argv, VALUE ary)

    { rb_ary_modify(ary); while (argc--) { rb_ary_push_1(ary, *argv++); } return ary; } 12年12月8日星期六
  10. people = { "Eddie" => ["green", "[email protected]"], "Joanne" => ["yellow",

    "[email protected]"] } people.map { |name, (color, email)| puts [name, email] } 12年12月8日星期六
  11. people = { "Eddie" => ["green", "[email protected]"], "Joanne" => ["yellow",

    "[email protected]"] } people.map { |name, (_, email)| puts [name, email] } parse.y#8277-8299 shadowing_lvar_gen() 12年12月8日星期六
  12. 高見見龍龍 Conacts photo by Eddie Websie Blog Plurk Facebook Google

    Plus Twiter Email Mobile http://www.eddie.com.tw http://blog.eddie.com.tw http://www.plurk.com/aquarianboy http://www.facebook.com/eddiekao http://www.eddie.com.tw/+ https://twiter.com/#!/eddiekao [email protected] +886-928-617-687 12年12月8日星期六