tailieunhanh - HandBooks Professional Java-C-Scrip-SQL part 248
Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 248', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | def foo end end class Bar Foo undef_method foo end b Class Class class A class named Class is a class for every class of Ruby - . This means classes are first-class objects in Ruby. Class can be created by a class statement. In addition even unnamed classes can be created by Class new. Inherited Class Module Inherited Class Object Class Methods Class inherited c Called when a subclass is defined. Used as a callback. Class new superclass Object Creates a new class. Instance Methods Class class doesn t inherit the module_function method. Alias for . Returns the class name. arg . Creates an instance of the class. Any arguments or blocks get passed directly to the initialize method of the object created. Returns the class s superclass. Proc Objects and Bindings The Proc class provides support for converting blocks into objects and manipulating them just like other objects in Ruby. The nice thing is that the Proc object you create can recreate its execution environment when you need to call it. Ruby also provides you with a tool for packaging up an execution environment for use later via the Binding class. Proc Procedure object class Proc is an objectified block that is given to a method. You can create a Proc object by calling the proc method or by using the block argument of the method. p1 proc a a 1 Proc from a block p2 proc Proc from a block given to this method def foo proc Proc from a block given to this method 42 invoke Proc equivalent to yield end Proc new Proc new x . Converts the block into a Proc object. If a block isn t passed the block associated with the calling method is converted into a Proc object. Equivalent to built-in functions lambda and proc. Instance Methods p arg. arg. Calls a Proc object. Returns the number of arguments accepted by a Proc objectp. For p that take a variable number of arguments returns -n-1 where n is the number of mandatory .
đang nạp các trang xem trước