Index: object.c =================================================================== --- object.c (Revision 48473) +++ object.c (Arbeitskopie) @@ -155,7 +155,7 @@ * capacity of a Fixnum will be truncated before being used. * * The hash value for an object may not be identical across invocations or - * implementations of ruby. If you need a stable identifier across ruby + * implementations of Ruby. If you need a stable identifier across Ruby * invocations and implementations you will need to generate one with a custom * method. */ @@ -234,7 +234,7 @@ * obj.singleton_class -> class * * Returns the singleton class of obj. This method creates - * a new singleton class if obj does not have it. + * a new singleton class if obj does not have one. * * If obj is nil, true, or * false, it returns NilClass, TrueClass, or FalseClass, @@ -302,9 +302,9 @@ * obj.clone -> an_object * * Produces a shallow copy of obj---the instance variables of - * obj are copied, but not the objects they reference. Copies - * the frozen and tainted state of obj. See also the discussion - * under Object#dup. + * obj are copied, but not the objects they reference. + * clone copies the frozen and tainted state of obj. + * See also the discussion under Object#dup. * * class Klass * attr_accessor :str @@ -352,8 +352,8 @@ * obj.dup -> an_object * * Produces a shallow copy of obj---the instance variables of - * obj are copied, but not the objects they reference. dup - * copies the tainted state of obj. + * obj are copied, but not the objects they reference. + * dup copies the tainted state of obj. * * This method may have class-specific behavior. If so, that * behavior will be documented under the #+initialize_copy+ method of @@ -367,7 +367,7 @@ * typically uses the class of the descendant object to create the new * instance. * - * When using #dup any modules that the object has been extended with will not + * When using #dup, any modules that the object has been extended with will not * be copied. * * class Klass @@ -450,7 +450,7 @@ * Returns a string representing obj. The default * to_s prints the object's class and an encoding of the * object id. As a special case, the top-level object that is the - * initial execution context of Ruby programs returns ``main.'' + * initial execution context of Ruby programs returns ``main''. */ VALUE @@ -467,7 +467,7 @@ /* * If the default external encoding is ASCII compatible, the encoding of - * inspected result must be compatible with it. + * the inspected result must be compatible with it. * If the default external encoding is ASCII incompatible, * the result must be ASCII only. */ @@ -536,9 +536,10 @@ * obj.inspect -> string * * Returns a string containing a human-readable representation of obj. - * By default, show the class name and the list of the instance variables and + * The default inspect shows the object's class name, + * an encoding of the object id, and a list of the instance variables and * their values (by calling #inspect on each of them). - * User defined classes should override this method to make better + * User defined classes should override this method to provide a better * representation of obj. When overriding this method, it should * return a string whose encoding is compatible with the default external * encoding. @@ -556,13 +557,6 @@ * end * end * Bar.new.inspect #=> "#" - * - * class Baz - * def to_s - * "baz" - * end - * end - * Baz.new.inspect #=> "#" */ static VALUE @@ -683,16 +677,16 @@ /* * call-seq: - * obj.tap{|x|...} -> obj + * obj.tap{|obj| ... } -> obj * - * Yields x to the block, and then returns x. + * Yields self to the block, and then returns self. * The primary purpose of this method is to "tap into" a method chain, * in order to perform operations on intermediate results within the chain. * - * (1..10) .tap {|x| puts "original: #{x.inspect}"} - * .to_a .tap {|x| puts "array: #{x.inspect}"} - * .select {|x| x%2==0} .tap {|x| puts "evens: #{x.inspect}"} - * .map { |x| x*x } .tap {|x| puts "squares: #{x.inspect}"} + * (1..10) .tap {|x| puts "original: #{x.inspect}" } + * .to_a .tap {|x| puts "array: #{x.inspect}" } + * .select {|x| x%2==0 } .tap {|x| puts "evens: #{x.inspect}" } + * .map {|x| x*x } .tap {|x| puts "squares: #{x.inspect}" } * */ @@ -726,7 +720,7 @@ * class Baz < Bar * end * - * produces: + * produces: * * New subclass: Bar * New subclass: Baz @@ -748,7 +742,7 @@ * def some_instance_method() end * end * - * produces: + * produces: * * Adding :some_instance_method * @@ -774,7 +768,7 @@ * remove_method :some_instance_method * end * - * produces: + * produces: * * Removing :some_instance_method * @@ -962,13 +956,13 @@ * * Objects that are marked as tainted will be restricted from various built-in * methods. This is to prevent insecure data, such as command-line arguments - * or strings read from Kernel#gets, from inadvertently compromising the users + * or strings read from Kernel#gets, from inadvertently compromising the user's * system. * - * To check whether an object is tainted, use #tainted? + * To check whether an object is tainted, use #tainted?. * * You should only untaint a tainted object if your code has inspected it and - * determined that it is safe. To do so use #untaint + * determined that it is safe. To do so use #untaint. * * In $SAFE level 3, all newly created objects are tainted and you can't untaint * objects. @@ -1247,7 +1241,7 @@ * call-seq: * true | obj -> true * - * Or---Returns true. As anObject is an argument to + * Or---Returns true. As obj is an argument to * a method call, it is always evaluated; there is no short-circuit * evaluation in this case. * @@ -1371,10 +1365,12 @@ /* * call-seq: - * nil.nil? -> true - * .nil? -> false + * obj.nil? -> true or false * * Only the object nil responds true to nil?. + * + * Object.new.nil? #=> false + * nil.nil? #=> true */ @@ -1451,7 +1447,7 @@ * Instance methods appear as methods in a class when the module is * included, module methods do not. Conversely, module methods may be * called without creating an encapsulating object, while instance - * methods may not. (See Module#module_function) + * methods may not. (See Module#module_function.) * * In the descriptions that follow, the parameter sym refers * to a symbol, which is either a quoted string or a @@ -1474,7 +1470,7 @@ * call-seq: * mod.to_s -> string * - * Return a string representing this module or class. For basic + * Returns a string representing this module or class. For basic * classes and modules, this is the name. For singletons, we * show information on the thing we're attached to as well. */ @@ -1534,7 +1530,7 @@ * call-seq: * mod === obj -> true or false * - * Case Equality---Returns true if anObject is an + * Case Equality---Returns true if obj is an * instance of mod or one of mod's descendants. Of * limited use for modules, but can be used in case * statements to classify objects by class. @@ -1554,7 +1550,7 @@ * is the same as other. Returns * nil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class Amod is a subclass of other. Returns * nil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class Anil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class AA"). + * "class AA".) * */ @@ -1626,7 +1622,7 @@ * Returns true if mod is an ancestor of other. Returns * nil if there's no relationship between the two. * (Think of the relationship in terms of the class definition: - * "class AA"). + * "class AA".) * */ @@ -1884,7 +1880,7 @@ * class Bar < Foo; end * Bar.superclass #=> Foo * - * returns nil when the given class hasn't a parent class: + * Returns nil when the given class does not have a parent class: * * BasicObject.superclass #=> nil * @@ -2059,9 +2055,9 @@ * mod.const_get(sym, inherit=true) -> obj * mod.const_get(str, inherit=true) -> obj * - * Checks for a constant with the given name in mod + * Checks for a constant with the given name in mod. * If +inherit+ is set, the lookup will also search - * the ancestors (and +Object+ if mod is a +Module+.) + * the ancestors (and +Object+ if mod is a +Module+). * * The value of the constant is returned if a definition is found, * otherwise a +NameError+ is raised. @@ -2087,7 +2083,7 @@ * Object.const_get 'Foo::Baz::VAL' # => 10 * Object.const_get 'Foo::Baz::VAL', false # => NameError * - * If neither +sym+ nor +str+ is not a valid constant name a NameError will be + * If the argument is not a valid constant name a +NameError+ will be * raised with a warning "wrong constant name". * * Object.const_get 'foobar' #=> NameError: wrong constant name foobar @@ -2199,7 +2195,7 @@ * Math.const_set("HIGH_SCHOOL_PI", 22.0/7.0) #=> 3.14285714285714 * Math::HIGH_SCHOOL_PI - Math::PI #=> 0.00126448926734968 * - * If neither +sym+ nor +str+ is not a valid constant name a NameError will be + * If +sym+ or +str+ is not a valid constant name a +NameError+ will be * raised with a warning "wrong constant name". * * Object.const_set('foobar', 42) #=> NameError: wrong constant name foobar @@ -2248,7 +2244,7 @@ * * In this case, the same logic for autoloading applies. * - * If the argument is not a valid constant name +NameError+ is raised with the + * If the argument is not a valid constant name a +NameError+ is raised with the * message "wrong constant name _name_": * * Hash.const_defined? 'foobar' #=> NameError: wrong constant name foobar @@ -2401,10 +2397,10 @@ * obj.instance_variable_set(symbol, obj) -> obj * obj.instance_variable_set(string, obj) -> obj * - * Sets the instance variable names by symbol to - * object, thereby frustrating the efforts of the class's + * Sets the instance variable named by symbol to the given + * object, thereby frustrating the efforts of the class's * author to attempt to provide proper encapsulation. The variable - * did not have to exist prior to this call. + * does not have to exist prior to this call. * If the instance variable name is passed as a string, that string * is converted to a symbol. * @@ -2474,7 +2470,7 @@ * * Returns the value of the given class variable (or throws a * NameError exception). The @@ part of the - * variable name should be included for regular class variables + * variable name should be included for regular class variables. * String arguments are converted to symbols. * * class Fred @@ -2510,8 +2506,8 @@ * obj.class_variable_set(symbol, obj) -> obj * obj.class_variable_set(string, obj) -> obj * - * Sets the class variable names by symbol to - * object. + * Sets the class variable named by symbol to the given + * object. * If the class variable name is passed as a string, that string * is converted to a symbol. * @@ -2777,18 +2773,18 @@ /* * call-seq: - * Integer(arg,base=0) -> integer + * Integer(arg, base=0) -> integer * * Converts arg to a Fixnum or Bignum. * Numeric types are converted directly (with floating point numbers - * being truncated). base (0, or between 2 and 36) is a base for + * being truncated). base (0, or between 2 and 36) is a base for * integer string representation. If arg is a String, - * when base is omitted or equals to zero, radix indicators + * when base is omitted or equals zero, radix indicators * (0, 0b, and 0x) are honored. * In any case, strings should be strictly conformed to numeric * representation. This behavior is different from that of - * String#to_i. Non string values will be converted using - * to_int, and to_i. Passing nil + * String#to_i. Non string values will be converted by first + * trying to_int, then to_i. Passing nil * raises a TypeError. * * Integer(123.999) #=> 123 @@ -2962,8 +2958,8 @@ * Float(arg) -> float * * Returns arg converted to a float. Numeric types are converted - * directly, the rest are converted using arg.to_f. As of Ruby - * 1.8, converting nil generates a TypeError. + * directly, the rest are converted using arg.to_f. + * Converting nil generates a TypeError. * * Float(1) #=> 1.0 * Float("123.456") #=> 123.456 @@ -3035,7 +3031,7 @@ * call-seq: * String(arg) -> string * - * Returns arg as an String. + * Returns arg as a String. * * First tries to call its to_str method, then its to_s method. * @@ -3070,7 +3066,7 @@ * * Returns +arg+ as an Array. * - * First tries to call Array#to_ary on +arg+, then Array#to_a. + * First tries to call to_ary on +arg+, then to_a. * * Array(1..5) #=> [1, 2, 3, 4, 5] */ @@ -3125,7 +3121,7 @@ * Typically, you create a new class by using: * * class Name - * # some class describing the class behavior + * # some code describing the class behavior * end * * When a new class is created, an object of type Class is initialized and @@ -3137,27 +3133,25 @@ * Class: * * class Class - * alias oldNew new - * def new(*args) - * print "Creating a new ", self.name, "\n" - * oldNew(*args) - * end - * end + * alias old_new new + * def new(*args) + * print "Creating a new ", self.name, "\n" + * old_new(*args) + * end + * end * + * class Name + * end * - * class Name - * end + * n = Name.new * - * - * n = Name.new - * * produces: * * Creating a new Name * * Classes, modules, and objects are interrelated. In the diagram * that follows, the vertical arrows represent inheritance, and the - * parentheses meta-classes. All metaclasses are instances + * parentheses metaclasses. All metaclasses are instances * of the class `Class'. * +---------+ +-... * | | | @@ -3218,7 +3212,7 @@ * * BasicObject does not include Kernel (for methods like +puts+) and * BasicObject is outside of the namespace of the standard library so common - * classes will not be found without a using a full class path. + * classes will not be found without using a full class path. * * A variety of strategies can be used to provide useful portions of the * standard library to subclasses of BasicObject. A subclass could @@ -3256,7 +3250,7 @@ * * Object is the default root of all Ruby objects. Object inherits from * BasicObject which allows creating alternate object hierarchies. Methods - * on object are available to all classes unless explicitly overridden. + * on Object are available to all classes unless explicitly overridden. * * Object mixes in the Kernel module, making the built-in kernel functions * globally accessible. Although the instance methods of Object are defined