Class: Peruby::Op::ModifierFor
- Includes:
- LoopExecution
- Defined in:
- lib/peruby/op/loop.rb
Overview
Statement modifier: EXPR for LIST, with $_ aliased to each source cell.
Instance Method Summary collapse
-
#initialize(expression, list) ⇒ ModifierFor
constructor
A new instance of ModifierFor.
- #run(env, _context) ⇒ Object
Methods inherited from Base
#argument_cells, #local_slot, #lvalue, #run_subroutine, #to_callable, #warning_directive?
Constructor Details
#initialize(expression, list) ⇒ ModifierFor
Returns a new instance of ModifierFor.
114 115 116 117 118 119 |
# File 'lib/peruby/op/loop.rb', line 114 def initialize(expression, list) @expression = expression @body = expression @list = list @label = nil end |
Instance Method Details
#run(env, _context) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/peruby/op/loop.rb', line 121 def run(env, _context) @list.run(env, :list).each do |cell| keep_going = true env.with_scope do env.bind(:scalar, '_', cell) keep_going = run_iteration?(env) end break unless keep_going end nil end |