Last active
December 12, 2015 12:29
-
-
Save kotp/4772181 to your computer and use it in GitHub Desktop.
Exploring modules, constants and methods
This 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 characters
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 | |
This 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 characters
require './global_var' | |
include SharedVar | |
puts GlobalConstant | |
puts $GlobalConstant_WithDollarSign | |
puts SharedVar::NAMESPACED_CONSTANT | |
puts SharedVar::your_method | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
unless you're building a gem