class Chef::Decorator::LazyArray

Lazy Array around Lazy Objects

This makes access lazy through ‘#[]`. In order to implement each we need to know how many items we have and what their indexes are, so we’d have to evaluate the proc which makes that impossible. You can call methods like each and the decorator will forward the method, but item access will not be lazy.

at() and fetch() are not implemented but technically could be.

@example

  def foo
      puts "allocated"
        "value"
  end

  a = Chef::Decorator::LazyArray.new { [ foo ] }

  puts "started"
  a[0]
  puts "still lazy"
  puts a[0]

outputs:

  started
  still lazy
  allocated
  value

@since 12.10.x