 
 This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.
| Automatically Loading Files as Needed | ||
|---|---|---|
| Code | Expected | Actual | 
| module Decidable # ... Many, many methods go here. end module Semidecidable # ... Many, many methods go here. end | functions.rb | |
| autoload :Decidable, "decidable.rb" autoload :Semidecidable, "semidecidable.rb" | decidable.rb | |
| module Decidable # ... Many, many methods go here. end | semidecidable.rb | |
| module Semidecidable # ... Many, many methods go here. end require 'functions' Decidable.class | Module | Module | 
| autoload :Set, "set.rb" def random_set(size) max = size * 10 set = Set.new set << rand(max) until set.size == size return set end | More code goes here... | |
| random_set(10) | #<Set: {39, 83, 73, 40, 90, 25, 91, 31, 76, 54}> | #<Set: {39, 83, 73, 40, 90, 25, 91, 31, 76, 54}> | 
| require 'set' | false | false |