Sha256: cd51cf27e4590388357dda314ab3edcc0f2db77f4a45a5d811b3dbf83b7c8a70

Contents?: true

Size: 610 Bytes

Versions: 4

Compression:

Stored size: 610 Bytes

Contents

# frozen_string_literal: true

require 'singleton' # Use the Singleton design pattern
require_relative 'builtin_datatype'

module Loxxy
  module Datatype
    # Class for representing a Lox nil "value".
    class Nil < BuiltinDatatype
      include Singleton # Make a singleton class

      # Build the sole instance
      def initialize
        super(nil)
      end

      # Method called from Lox to obtain the text representation of nil.
      # @return [String]
      def to_str
        'nil'
      end
    end # class

    Nil.instance.freeze # Make the sole instance immutable
  end # module
end # module

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
loxxy-0.0.15 lib/loxxy/datatype/nil.rb
loxxy-0.0.14 lib/loxxy/datatype/nil.rb
loxxy-0.0.13 lib/loxxy/datatype/nil.rb
loxxy-0.0.12 lib/loxxy/datatype/nil.rb