Class: RVM::Interpreter::Return

Inherits:
Object
  • Object
show all
Defined in:
lib/rvm/interpreter.rb

Overview

Represents the return statement, it throws a ReturnException which can be caught to have the function or block return what they wish.

Instance Method Summary collapse

Constructor Details

#initialize(val, pos = nil) ⇒ Return

Returns a new instance of Return.



492
493
494
495
# File 'lib/rvm/interpreter.rb', line 492

def initialize val, pos = nil
  @val = val
  @pos = pos
end

Instance Method Details

#data_typeObject



497
498
499
# File 'lib/rvm/interpreter.rb', line 497

def data_type
  :any
end

#execute(env) ⇒ Object

Raises:



501
502
503
# File 'lib/rvm/interpreter.rb', line 501

def execute env
  raise ReturnException.new(@val.execute(env))
end