C Extensions – Writing Inline C – RubyInLine
RubyInline is a framework that lets you embed other languages inside your Ruby code. It defines the Module# inline metho...
RubyInline is a framework that lets you embed other languages inside your Ruby code. It defines the Module# inline metho...
The double-quoted delimiter " and %Q sequence supports string interpolation using #{ruby_expression}: puts "No...
The process number of the Ruby running this script if you want to reproduce, please indicate the source: Special Constan...
A mixin is just a module that can be added (mixed in) to a class. one way to do it is with the extend method. The extend...
Contains the subpattern from the corresponding set of parentheses in the last successful pattern matched, not counting p...
If an array happens to have one or more nil elements and these need to be removed, the Array#compact or Array#compact! m...
Inject and reduce are different names for the same thing. In other languages these functions are often called folds (lik...
Ruby uses the case keyword for switch statements. As per the Ruby Docs: Case statements consist of an optional condition...
Classes have 3 types of methods: instance, singleton and class methods. Instance Methods These are methods that can be c...
Modules can contain other modules and classes: module Namespace module Child class Foo; end end # module Child # Foo can...
You can use Modules to build more complex classes through composition. The include ModuleName directive incorporates a m...
The round method will round a number up if the first digit after its decimal place is 5 or higher and round down if that...
You can easily do something to each element in a range. (1..5).each do |i| print i end # 12345 if you want to reproduce,...
A string can be written to a file with an instance of the File class. file = File.new('tmp.txt', 'w') file.write("N...
Methods are defined with the def keyword, followed by the method name and an optional list of parameter names in parenth...