Skip to content

Instantly share code, notes, and snippets.

@zaben903
Last active December 13, 2022 09:07
Show Gist options
  • Save zaben903/51a942898432cc0352991ca44a2455b6 to your computer and use it in GitHub Desktop.
Save zaben903/51a942898432cc0352991ca44a2455b6 to your computer and use it in GitHub Desktop.
Ruby requires
# somename.rb
class Somename
def self.example
puts 'Somename example'
end
end
class Othername
def self.example
puts 'Othername example'
end
end
# mylib.rb
require_relative './somename'
Somename.example
Othername.example
# Bash
$ ruby ./mylib.rb
Somename example
Othername example
# somename.rb
class Somename
def self.example
puts 'Somename example'
end
end
class Somename
def self.example_two
puts 'Othername example'
end
end
# mylib.rb
require_relative './somename'
Somename.example
Somename.example_two
# Bash
$ ruby ./mylib.rb
Somename example
Othername example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment