Created
          October 23, 2022 20:34 
        
      - 
      
- 
        Save seanhandley/86fdb340c9eb1b9714f6fb3e6bf43882 to your computer and use it in GitHub Desktop. 
Revisions
- 
        seanhandley created this gist Oct 23, 2022 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ irb(main):001:1* def make_methods(&blk) irb(main):002:1* (1..100).each { |i| define_method("number_#{i}".to_sym) { blk.call(i) } } irb(main):003:0> end => :make_methods irb(main):004:0> irb(main):005:0> make_methods { |i| i } => 1..100 irb(main):006:0> irb(main):007:0> puts number_2 # => 2 2 => nil irb(main):008:0> puts number_3 # => 3 3 => nil irb(main):009:0> irb(main):010:0> p method(:number_2).source_location ["(irb)", 2] => ["(irb)", 2] irb(main):011:0> irb(main):012:0> make_methods { |i| i * 2} => 1..100 irb(main):013:0> irb(main):014:0> puts number_2 # => 4 4 => nil irb(main):015:0> puts number_3 # => 6 6 => nil irb(main):016:0> irb(main):017:0> p method(:number_2).source_location ["(irb)", 2] => ["(irb)", 2] irb(main):018:0>