inspect
displays an object in some defined, human-readable form, showing instance variables.
/asdf/
%r{asdf}
=~
for finding index of matchesRegexp.quote(foo)
escapes all special characters in the the string foofoo = "asdf"
, if "asdfsdf" =~ /#{Regexp.quote(foo)}/
File.join(args)
joins the arguements to make a file path based on File::SEPARATOR
Modules group together methods, classes, constants.
include
a module in a class definition, then all module's instance methods are mixed in. So, mix-in modules effectively behave as superclasses.include
include
has nothing to do with files. It references a named module currently accessible. Does not copy functions into a class, creates a reference to them. With multiple classes including, they all point to the same thing.
For some class, you can use ruby's built in Comparable
mixin, and def <=>(other)
to define how to compare two objects.
def each
: then include Enumerable
module, which defines map
, include?
, find_all?
def <=>(other)
: then max
, min
, sort
are availableautoload :MyLibrary, 'mylibrary'
works like require 'mylibrary'
but it only loads dependencies on the first time they're used rather than during the call itself. Symbol is the classname assigned, ruby file to be loaded is found using the relative file directory location.
Array#Permutation
Array#Combination