ruby 1.8 differences?

Discussion in 'Ruby' started by Glenn, May 2, 2004.

  1. Glenn

    Glenn Guest

    Can anybody point me at a list of what's changed in Ruby
    version-for-version? I'm reading the web-based docs and I'd like to
    know what's improved in the version I've started using (1.8.13rc2 as
    of yesterday if memory serves). On Windows (he ducks)...!
     
    Glenn, May 2, 2004
    #1
    1. Advertising

  2. Glenn

    Tim Hunter Guest

    Tim Hunter, May 2, 2004
    #2
    1. Advertising

  3. At 03:31 03/05/2004 +0900, you wrote:

    >--- Glenn <> wrote:
    > > Can anybody point me at a list of what's changed in Ruby
    > > version-for-version? I'm reading the web-based docs and I'd like to
    > > know what's improved in the version I've started using (1.8.13rc2 as
    > > of yesterday if memory serves). On Windows (he ducks)...!
    > >

    >
    >Here's a good article by Why,
    >
    >http://www.whytheluckystiff.net/articles/rubyOneEightOh.html


    This is incredibly useful ! I specially liked the sort_by thing.

    I started refactoring my code to use it. But I use a lot of sort!()
    and sort_by! does not exists :-(

    Question : Why no sort_by!() ?
    Nota: Maybe I should not use sort!() that much. In some cases
    I am assuming that it will be more efficient than x = x.sort(),
    but I may be wrong.

    initialize_copy() is great too. For a long time I was unsure
    about how to implement copy constructors. Most of the time
    my initialize() had to look at its parameters to figure out
    what to do and to copy construct if one its parameter was
    another object to use as a prototype. Now, I can get rid of
    that ugly code.

    Yours,

    Jean-Hugues





    >
    >
    >__________________________________
    >Do you Yahoo!?
    >Win a $20,000 Career Makeover at Yahoo! HotJobs
    >http://hotjobs.sweepstakes.yahoo.com/careermakeover
    >hotjobs.sweepstakes.yahoo.com/careermakeover


    -------------------------------------------------------------------------
    Web: http://hdl.handle.net/1030.37/1.1
    Phone: +33 (0) 4 92 27 74 17
     
    Jean-Hugues ROBERT, May 3, 2004
    #3
  4. At 06:03 03/05/2004 +0900, you wrote:
    >On Sun, 02 May 2004 11:13:24 -0700, Glenn wrote:
    > > Can anybody point me at a list of what's changed in Ruby
    > > version-for-version?

    >http://dev.faeriemud.org/changes-1.8.0.html


    Great too. I liked the Set class, great reading to learn
    Ruby.

    I tried Symbol#intern, strangely it is not defined for me...
    So I keep my "class Symbol; def intern() self end end"
    RUBY_VERSION == "1.8.1", RUBY_PLATFORM == "i386-mswin32"
    Typo ?

    Yours,

    Jean-Hugues


    -------------------------------------------------------------------------
    Web: http://hdl.handle.net/1030.37/1.1
    Phone: +33 (0) 4 92 27 74 17
     
    Jean-Hugues ROBERT, May 3, 2004
    #4
  5. Glenn

    Glenn Guest

    Thanks Tim!
     
    Glenn, May 3, 2004
    #5
  6. On 2004-05-03 20:23:41 +0900, Jean-Hugues ROBERT wrote:
    > I started refactoring my code to use it. But I use a lot of sort!()
    > and sort_by! does not exists :-(
    >
    > Question : Why no sort_by!() ?


    sort_by is a more efficent way of Schwartzian Transform (because it's
    implemented in C). So instead of

    ary.map {|x| [f(x), x] }.sort {|(ka,),(kb,)| ka <=> kb }.map { |k,v| v }

    you can just write:

    ary.sort_by { |x| f(x) }

    Temporary arrays are created anyway. That's why it is not useful to have
    sort_by!. In general Schwartzian Transform is a stupid idea, especially
    for large arrays, but sometimes it's possible to find a function f with
    an image that can be used for comparing the values more efficiently than
    the values themselves.

    Here's a perl-centered paper about a lot of sorting tricks, but most of
    it is also true for Ruby: "A Fresh Look at Efficient Perl Sorting",
    http://www.sysarch.com/perl/sort_paper.html

    --
    c, s, x = gets, c[0, 2].to_i, "dsfd;kfoA,.iyewrkldJKDHSUB"
    puts (1...(c.size / 2)).inject("") do |p, i|
    p << (c[2 * i, 2].to_i(16) ^ x[(s += 1) && s - 1])
    end
     
    Florian Frank, May 3, 2004
    #6
  7. Glenn

    daz Guest

    On 2004/05/03, Jean-Hugues ROBERT wrote:
    >
    > >http://dev.faeriemud.org/changes-1.8.0.html

    >
    > I tried Symbol#intern, strangely it is not defined for me...
    > So I keep my "class Symbol; def intern() self end end"
    > RUBY_VERSION == "1.8.1", RUBY_PLATFORM == "i386-mswin32"
    > Typo ?
    >
    > Yours,
    >
    > Jean-Hugues
    >


    #to_sym seems to be preferred over #intern.

    h = 'Hello'.to_sym

    p h # (from String) #-> :Hello
    p h.to_sym # (from Symbol) #-> :Hello
    p h.to_i.to_sym # (from Fixnum) #-> :Hello


    <doc\ChangeLog>

    Sat Nov 2 00:38:55 2002 Yukihiro Matsumoto <>

    * object.c (sym_to_sym): rename from Symbol#intern
     
    daz, May 19, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Home_Job_opportunity
    Replies:
    0
    Views:
    527
    Home_Job_opportunity
    Jan 8, 2009
  2. Home_Job_opportunity
    Replies:
    0
    Views:
    615
    Home_Job_opportunity
    Jan 14, 2009
  3. Sam Dela Cruz
    Replies:
    3
    Views:
    117
    Sam Dela Cruz
    Jan 10, 2006
  4. Aaron Smith

    ruby / php operator differences.

    Aaron Smith, Mar 8, 2007, in forum: Ruby
    Replies:
    8
    Views:
    139
    Aaron Smith
    Mar 10, 2007
  5. duddilla's
    Replies:
    12
    Views:
    331
    Robert Parker
    Dec 6, 2007
Loading...

Share This Page