View Single Post
  #4 (permalink)  
Old 03-30-2008, 09:40 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default Re: Ruby BuiltIn functions

abort
Terminate execution immediately, effectively by calling Kernel.exit(1).

Array
Array( arg ) -> anArray
Returns arg .to_a.
Array(1..5) » [1, 2, 3, 4, 5]


at_exit

at_exit { block } -> aProc
Converts block to a Proc object (and therefore binds it at the point of call) and registers it for execution when the program exits. If multiple handlers are registered, they are executed in reverse order of registration.

def do_at_exit(str1)
at_exit { print str1 }
end
at_exit { puts "cruel world" }
do_at_exit("goodbye ")
exit

produces:


goodbye cruel world


binding

binding -> aBinding

Returns a Binding object, describing the variable and method bindings at the point of call. This object can be used when calling eval to execute the evaluated command in this environment. Also see the description of Binding beginning on page 291.

def getBinding(param)
return binding
end
b = getBinding("hello")
eval "param", b » "hello"
__________________
Shaalini.S
Be the Best of Whatever you are...
Reply With Quote