Sha256: 77a059dc317e7d6d9e7b636054c1438e477ce7cabdb51e799cd74c895f312dd8

Contents?: true

Size: 484 Bytes

Versions: 1

Compression:

Stored size: 484 Bytes

Contents

require 'arrayfields'
#
# the struct/fields factory method can be used in much the same way as ruby's
# own struct generators and is useful when the fields for a set of arrays is
# known apriori
#
  c = Array.fields :a, :b, :c  # same as Array.struct
  a = c.new [42, nil, nil]
  a[:c] = 42
  p a                          #=> [42, nil, 42]
#
# of course we can append too
#
  a[:d] = 42.0
  p a[:d]                      #=> 42.0
  p a                          #=> [42, nil, 42, 42.0]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arrayfields-3.7.0 sample/b.rb