Module: Hamster::EmptyList

Extended by:
List
Defined in:
lib/hamster/list.rb

Overview

A list without any elements. This is a singleton, since all empty lists are equivalent.

Class Method Summary collapse

Methods included from List

<<, [], [], append, at, break, cached_size?, chunk, clear, combination, cons, cycle, delete, delete_at, drop, drop_while, dup, each, each_chunk, eql?, fill, flat_map, flatten, group_by, hash, indices, init, inits, insert, inspect, intersperse, last, map, merge, merge_by, partition, permutation, pop, reverse, rotate, sample, select, size, sort, sort_by, span, split_at, subsequences, tails, take, take_while, to_list, transpose, union, uniq, zip

Methods included from Enumerable

#<=>, #==, #compact, #each_index, #grep, #group_by, #inspect, #join, #partition, #product, #reject, #sum, #to_set

Methods included from Enumerable

#to_list

Class Method Details

.cached_size?Boolean

Returns:

  • (Boolean)

1441
1442
1443
# File 'lib/hamster/list.rb', line 1441

def cached_size?
  true
end

.empty?Boolean

Returns:

  • (Boolean)

1430
1431
1432
# File 'lib/hamster/list.rb', line 1430

def empty?
  true
end

.headnil Also known as: first

There is no first item in an empty list, so return nil.

Returns:

  • (nil)

1419
1420
1421
# File 'lib/hamster/list.rb', line 1419

def head
  nil
end

.sizeInteger Also known as: length

Return the number of items in this List.

Returns:

  • (Integer)

1436
1437
1438
# File 'lib/hamster/list.rb', line 1436

def size
  0
end

.tailself

There are no subsequent elements, so return an empty list.

Returns:

  • (self)

1426
1427
1428
# File 'lib/hamster/list.rb', line 1426

def tail
  self
end