Skip to content

Instantly share code, notes, and snippets.

@kotp
Last active December 12, 2015 12:29
Show Gist options
  • Save kotp/4772181 to your computer and use it in GitHub Desktop.
Save kotp/4772181 to your computer and use it in GitHub Desktop.
Exploring modules, constants and methods
puts "Loading global_var.rb"
GlobalConstant = 'GlobalConstant'
$GlobalConstant_WithDollarSign = 'Global Constant with Dollar Sign'
module SharedVar
NAMESPACED_CONSTANT = 'Named spaced constant'
def your_method
"Whatever your method would be."
end
end
require './global_var'
include SharedVar
puts GlobalConstant
puts $GlobalConstant_WithDollarSign
puts SharedVar::NAMESPACED_CONSTANT
puts SharedVar::your_method
@DouglasAllen
Copy link

require_relative 'global_var'

unless you're building a gem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment