T
Tony Montana
Hi fellas!
I use ruby 1.9.2, and I try to force working the example from the book
i'm reading "The well-grounded rubyist":
#stacklike.rb
module Stacklike
def stack
@stack ||= []
end
def add_to_stack(obj)
stack.push(obj)
end
def take_from_stack
stack.pop
end
end
#stack.rb
require "stacklike"
class Stack
include Stacklike
end
s = Stack.new
Both files under modules folder. When I running stack.rb I have the
error:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to
load -- stacklike (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from modules/stack.rb:1:in `<main>'
None of these methods does not work too:
require "modules/stacklike"
require "modules/stacklike.rb"
But
load "modules/stacklike.rb"
works fine!
I'm absolutely noob in ruby and any help is appreciated.
I use ruby 1.9.2, and I try to force working the example from the book
i'm reading "The well-grounded rubyist":
#stacklike.rb
module Stacklike
def stack
@stack ||= []
end
def add_to_stack(obj)
stack.push(obj)
end
def take_from_stack
stack.pop
end
end
#stack.rb
require "stacklike"
class Stack
include Stacklike
end
s = Stack.new
Both files under modules folder. When I running stack.rb I have the
error:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to
load -- stacklike (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from modules/stack.rb:1:in `<main>'
None of these methods does not work too:
require "modules/stacklike"
require "modules/stacklike.rb"
But
load "modules/stacklike.rb"
works fine!
I'm absolutely noob in ruby and any help is appreciated.