The classes and modules are naturally where the bulk of the changes lie. Some have had methods added; others have merely had method semantics shift a little. This list is mostly alphabetical by class or module name; the exception is at the bottom of the list where we've put all the miscellaneous items. The methods named here are instance methods, unless noted as class methods. Class Array fetch added. insert added. The new method arr.insert(n, x, y, z) acts just like arr[n,0] = [x,y,z], but returns self rather than the assigned value. sort! always returns self without checking for modification of the array's contents. This behavior may change and should not be relied on. Class Dir Dir.chdir has been extended to take a block. Like such methods as File.open, the operation is only in effect within the scope of the block. Dir.glob now supports metacharacters escaped by a backslash; wildcards and spaces may now be escaped at will. Dir.open now returns the block return value like File.open, not nil as in Ruby 1.6. Dir.chdir will warn only when it is invoked from multiple threads or when no block is specified. Module Enumerable all? added (detects whether all items fit a given criterion). any? added (detects whether any item fits the given criterion). inject added (analogous to Smalltalk's inject). sort_by added (sorts by specified field or key). Class File Class IO Module Math Math.acos(x) added. Math.asin(x) added. Math.atan(x) added. Math.cosh(x) added. Math.hypot(x,y) added. Math.sinh(x) added. Math.tanh(x) added. Class Module Class Object Class Proc Class Process Class Range step added (default is 1). to_ary added. It's now possible to use a construct such as a, b, c = 1..3 without using to_a. Class Regexp It's no longer legal to regard a standalone /re/ as meaning /re/ =~ $_ in a conditional. You must explicitly use the match operator ~ instead. options added. Regexp.last_match has been extended to take an optional argument. Class String= casecmp added (case-insensitive comparison). eql? has been changed to be always case sensitive. insert added; the method call str.insert(n, s2) acts like str[n, 0] = s2, but returns itself rather than the value of the assignment. lstrip, rstrip, lstrip!, and rstrip! have been added to strip only the left or right sides of a string, respectively. Class Symbol Class Time Other Classes and Modules Interrupt is now a subclass of SignalException, rather than Exception. Kernel.open has been extended so that when the third argument is a set of permission flags, the underlying call will be open(2), rather than fopen(3). Marshal will no longer dump anonymous classes/modules. The Regexp class has to_ary added for convenience in using the match method on the right-hand side in a multiple assignment. Previously, you had to say something like junk, m1, m2, m3 = regex.match(str).to_a, whereas now you can say junk, m1, m2, m3 = regex.match(str) (omitting the to_a). Method#== added. NameError and NoMethodError have moved; now NoMethodError is a subclass of NameError, which in turn is a subclass of StandardError. NotImplementError is obsolete because of its "broken English." Use NotImplementedError instead. A new module Signal has been added; it has the module functions Signal::trap and Signal::list. SystemCallError.=== added. Refer to the note on comparison of exception classes in the rescue clause (at the top of this appendix). SystemExit#status added. |