View Single Post
  #35 (permalink)  
Old 04-15-2008, 09:29 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Wink Re: Ruby BuiltIn functions

throw
throw( aSymbol [, anObject ] )


Transfers control to the end of the active catch block waiting for aSymbol. Raises NameError if there is no catch block for the symbol. The optional second parameter supplies a return value for the catch block, which otherwise defaults to nil. For examples, see Kernel::catch on page 413.

trace_var

trace_var( aSymbol, aCmd ) -> nil
trace_var( aSymbol ) {| val | block }-> nil
Controls tracing of assignments to global variables. The parameter aSymbol identifies the variable (as either a string name or a symbol identifier). cmd (which may be a string or a Proc object) or block is executed whenever the variable is assigned. The block or Proc object receives the variable's new value as a parameter. Also see Kernel::untrace_var .

trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
$_ = "hello"
$_ = ' there'

produces:


$_ is now 'hello'
$_ is now ' there'
__________________
Shaalini.S
Be the Best of Whatever you are...
Reply With Quote