class Reference

Overview

Reference is the base class of classes you define in your program. It is set as a class' superclass when you don't specify one:

class MyClass # < Reference
end

A reference type is passed by reference: when you pass it to methods, return it from methods or assign it to variables, a pointer is actually passed.

Invoking new on a Reference allocates a new instance on the heap. The instance's memory is automatically freed (garbage-collected) when the instance is no longer referred by any other entity in the program.

Superclass hierarchy

Object
Reference

Direct Known Subclasses

Array(T), Array::IndexIterator(T), Array::ItemIterator(T), Array::ReverseIterator(T), Benchmark::BM::Job, Benchmark::BM::Tms, Benchmark::IPS::Entry, Benchmark::IPS::Job, BitArray, Box(T), BufferedIO(T), Channel(T), ConditionVariable, Crypto::Blowfish, Crypto::MD5, CSV::Builder, CSV::Lexer, CSV::Parser, Dir, ECR::Lexer, ECR::Lexer::Token, Exception, Fiber, FileDescriptorIO, Hash(K, V), Hash::Entry(K, V), Hash::EntryIterator(K, V), Hash::KeyIterator(K, V), Hash::ValueIterator(K, V), HTTP::Client, HTTP::Content, HTTP::Handler, HTTP::Request, HTTP::Response, HTTP::Server, HTTP::WebSocket, HTTP::WebSocketHandler::WebSocketSession, IniFile, Int::DowntoIterator(T, N), Int::TimesIterator(T), Int::UptoIterator(T, N), IO::ARGF, Iterator::Chain(I1, I2, T1, T2), Iterator::CycleN(I, T, N), Iterator::Skip(I, T), Iterator::SkipWhile(I, T, U), Iterator::Stop, Iterator::Take(I, T), Iterator::TakeWhile(I, T, U), Iterator::WithIndex(I, T), JSON::Lexer, JSON::Parser, JSON::PrettyWriter, JSON::PullParser, JSON::Token, LLVM::ABI, LLVM::ABI::FunctionType, LLVM::Context, Logger(T), Macros::ASTNode, Markdown, Markdown::HTMLRenderer, Markdown::Parser, MatchData, Matrix(T), Matrix::ColumnIterator(T), Matrix::IndexIterator(T), Matrix::ItemIterator(T), Matrix::RowIterator(T), Mutex, Number::StepIterator(T, L, B), OAuth2::AccessToken, OAuth2::Client, OAuth2::Session, OAuth::AccessToken, OAuth::Consumer, OAuth::RequestToken, OpenSSL::HMAC, OpenSSL::MD5, OpenSSL::SHA1, OpenSSL::SSL::Context, OpenSSL::SSL::Socket, OptionParser, Process::Status, Random::MT19937, Range::ItemIterator(B, E), Range::StepIterator(B, E), Regex, Scheduler, Slice::ItemIterator(T), Spec::Be(T), Spec::BeAExpectation(T), Spec::BeExpectation(T), Spec::BeFalseyExpectation, Spec::BeTruthyExpectation, Spec::CloseExpectation, Spec::ContainExpectation(T), Spec::Context, Spec::EqualExpectation(T), Spec::Formatter, Spec::MatchExpectation(T), String, String::Builder, String::CharIterator, String::LineIterator, StringIO, StringPool, StringScanner, Thread(T, R), Tuple::ItemIterator(T), URI, YAML::Parser

Defined in:

Instance Method Summary

Instance Method Detail

def !

Returns false: a reference is always truthy.


def ==(other : self)

Returns true if this reference is the same as other. Invokes #same?


def ==(other)

Returns false (other can only be a Value here).


def hash

Returns this reference's object_id as the hash value.


def inspect(io : IO) : Nil

def nil?

Returns false: a reference is never nil.


def same?(other : Reference)

Returns true if this reference is the same as other. This is only true if this reference's object_id is the same as other's.


def same?(other : Nil)

Returns false: a reference is never nil.


def to_s(io : IO) : Nil