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.
Direct Known Subclasses
- Array(T)
 - Benchmark::BM::Job
 - Benchmark::BM::Tms
 - Benchmark::IPS::Entry
 - Benchmark::IPS::Job
 - Box(T)
 - Channel(T)
 - Crypto::Bcrypt
 - Crypto::Bcrypt::Password
 - Crypto::Blowfish
 - Crypto::MD5
 - Crystal::Macros::ASTNode
 - CSV
 - CSV::Builder
 - CSV::Lexer
 - CSV::Parser
 - Deque(T)
 - Dir
 - ECR::Lexer::Token
 - Event::SignalChildHandler
 - Event::SignalHandler
 - Exception
 - Fiber
 - Hash(K, V)
 - HTTP::Client
 - HTTP::Client::Response
 - HTTP::Cookie
 - HTTP::Cookies
 - HTTP::Handler
 - HTTP::Request
 - HTTP::Server
 - HTTP::Server::Context
 - HTTP::Server::RequestProcessor
 - HTTP::Server::Response
 - HTTP::WebSocket
 - HTTP::WebSocket::Protocol::StreamIO
 - INI
 - IO::FileDescriptor
 - IPSocket::DnsRequestCbArg
 - Iterator::Stop
 - JSON::Lexer
 - JSON::Parser
 - JSON::PrettyWriter
 - JSON::PullParser
 - JSON::Token
 - Levenshtein::Finder
 - LLVM::ABI
 - LLVM::ABI::FunctionType
 - LLVM::Builder
 - LLVM::Context
 - LLVM::FunctionPassManager
 - LLVM::GenericValue
 - LLVM::JITCompiler
 - LLVM::Module
 - LLVM::ModulePassManager
 - LLVM::PassManagerBuilder
 - LLVM::TargetMachine
 - Logger
 - Markdown
 - Markdown::HTMLRenderer
 - Markdown::Parser
 - MemoryIO
 - Mutex
 - OAuth2::AccessToken
 - OAuth2::Client
 - OAuth2::Session
 - OAuth::AccessToken
 - OAuth::Consumer
 - OAuth::RequestToken
 - OpenSSL::Cipher
 - OpenSSL::Digest
 - OpenSSL::HMAC
 - OpenSSL::MD5
 - OpenSSL::SHA1
 - OpenSSL::SSL::Context
 - OpenSSL::SSL::Socket
 - OpenSSL::X509::Certificate
 - OpenSSL::X509::Extension
 - OpenSSL::X509::Name
 - OptionParser
 - Process
 - Process::Status
 - Random::MT19937
 - Regex
 - Regex::MatchData
 - Slice::ReverseIterator(T)
 - Spec::VerboseFormatter::Item
 - String
 - String::Builder
 - StringPool
 - StringScanner
 - Tuple::ItemIterator(I, T)
 - URI
 - YAML::Generator
 - YAML::Parser
 - YAML::PullParser
 - Zlib::Deflate
 - Zlib::Inflate
 
Defined in:
primitives.crreference.cr
Instance Method Summary
- 
        #==(other)
        
          
Returns false (other can only be a
Valuehere). - 
        #==(other : self)
        
          
Returns true if this reference is the same as other.
 - 
        #dup
        
          
Returns a shallow copy of this object.
 - 
        #hash
        
          
Returns this reference's
#object_idas the hash value. - #inspect(io : IO) : Nil
 - 
        #object_id : UInt64
        
          
Returns a UInt64 that uniquely identifies this object.
 - 
        #same?(other : Reference)
        
          
Returns true if this reference is the same as other.
 - 
        #same?(other : Nil)
        
          
Returns false: a reference is never nil.
 - #to_s(io : IO) : Nil
 
Instance methods inherited from class Object
  
  
    
      !=(other)
    !=, 
    
  
    
      !~(other)
    !~, 
    
  
    
      ==(other)
    ==, 
    
  
    
      ===(other)===(other : YAML::Any)
===(other : JSON::Any) ===, =~(other) =~, class class, crystal_type_id crystal_type_id, dup dup, hash hash, inspect(io : IO)
inspect inspect, itself itself, not_nil! not_nil!, tap(&block) tap, to_json to_json, to_pretty_json(io : IO)
to_pretty_json to_pretty_json, to_s
to_s(io : IO) to_s, to_yaml
to_yaml(io : IO) to_yaml, try(&block) try
Class methods inherited from class Object
  
  
    
      ==(other : Class)
    ==, 
    
  
    
      ===(other)
    ===, 
    
  
    
      cast(other) : self
    cast, 
    
  
    
      clone
    clone, 
    
  
    
      dup
    dup, 
    
  
    
      from_json(string_or_io, root : String) : selffrom_json(string_or_io) : self from_json, from_yaml(string : String) : self from_yaml, hash hash, inspect(io) inspect, name : String name, to_s(io) to_s, |(other : U.class) |
Instance Method Detail
Returns a shallow copy of this object.
This allocates a new object and copies the contents of
self into it.
Returns a UInt64 that uniquely identifies this object.
The returned value is the memory address of this object.
string = "hello"
string.object_id # => 4460249568
pointer = Pointer(String).new(string.object_id)
string2 = pointer.as(String)
string2.object_id == string.object_id # => trueReturns 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.