Accessing variables from included files in Ruby

Posted by nickf on Stack Overflow See other posts from Stack Overflow or by nickf
Published on 2010-05-18T01:15:11Z Indexed on 2010/05/18 1:20 UTC
Read the original article Hit count: 341

Filed under:
|
|

How do you access variables which are defined in an included file?

# inc.rb
foo = "bar";


# main.rb
require 'inc.rb'
puts foo

# NameError: undefined local variable or method `foo' for main:Object

© Stack Overflow or respective owner

Related posts about ruby

Related posts about beginner