The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
What's new in Ruby 1.9, Feb. 07 update

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eigen Class

Posts: 358
Nickname: eigenclass
Registered: Oct, 2005

Eigenclass is a hardcore Ruby blog.
What's new in Ruby 1.9, Feb. 07 update Posted: Feb 7, 2007 9:18 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eigen Class.
Original Post: What's new in Ruby 1.9, Feb. 07 update
Feed Title: Eigenclass
Feed URL: http://feeds.feedburner.com/eigenclass
Feed Description: Ruby stuff --- trying to stay away from triviality.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eigen Class
Latest Posts From Eigenclass

Advertisement

Yet another update to the list of changes in Ruby 1.9, covering new stuff between Oct. 06 and Jan. 07.

There are two major events which you won't find in that list (since they don't affect the language itself) but deserve nonetheless a mention. In Dec. 06 Koichi Sasada migrated Ruby's source repository to Subversion, paving the way for the merge of YARV*1 with Ruby 1.9. matz is now also working on a separate branch (matzruby), with more experimental features.

These are the most relevant language/core modifications during the covered period of time:

Symbol

It isn't a subclass of String anymore. This experiment lived exactly for two months (Sep. 2nd to Nov. 2nd).

Method#receiver, #name and #owner

Returns the receiver of a Method object, the name and the class or module where it was defined, respectively.

class A; def foo; end end
a = A.new
a.method(:foo).receiver                # => #<A:0xa7d3c938>
a.method(:foo).owner                   # => A
a.method(:foo).name                    # => "foo"

Line length limit in IO operations

IO operations that read a line accept an argument to specify the maximum amount of data to be read.

The affected methods are IO#gets, IO#readline, IO#readlines, IO#each_line, IO#lines, IO.foreach, IO.readlines, StringIO#gets, StringIO#readline, String IO#each and StringIO#readlines.

The limit is specified either as the (optional) second argument, or by passing a single integer argument (i.e. the first argument is interpreted as the limit if it's an integer, as a line separator otherwise)

IO#lines and IO#bytes

These new methods behave like String#lines and #bytes (also new in 1.9), returning an enumerator.

String#unpack with a block

If given a block, String#unpack will call it with the unpacked values instead of creating an array.

RUBY_VERSION                                      # => "1.9.0"
RUBY_RELEASE_DATE                                 # => "2007-02-07"
s = (0..4).to_a.pack("V*")
a = []
s.unpack("V*"){|x| a << x}
a                                                 # => [0, 1, 2, 3, 4]

String#lines

String#lines accepts an extra argument to indicate the line separator.

If given a block, #lines behaves like #each_line (ruby-core:9218).

Object#tap


Read more...

Read: What's new in Ruby 1.9, Feb. 07 update

Topic: Ruby on Rails article published on Developer.com Previous Topic   Next Topic Topic: Stikkit

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use