Slashdot Mirror


Ruby 2.1.0 Released

Today marks the release of Ruby version 2.1.0. A brief list of changes since 2.0.0 has been posted, and file downloads are available. Here are some of the changes:
  • Now the default values of keyword arguments can be omitted. Those 'required keyword arguments" need giving explicitly at the call time.
  • Added suffixes for integer and float literals: 'r', 'i', and 'ri'.
  • def-expr now returns the symbol of its name instead of nil.
  • rb_profile_frames() added. Provides low-cost access to the current ruby stack for callstack profiling.
  • introduced the generational GC a.k.a RGenGC (PDF).

3 of 65 comments (clear)

  1. For a dying language Ruby is doing great by ohnocitizen · · Score: 5, Funny

    What comedic timing: Is Ruby Dying.

  2. Too bad by filmorris · · Score: 4, Insightful

    Wow, just yesterday it was dying, and today they release a new version! I guess they didn't get the memo

    --
    "Hello, IT... Have you tried turning it off and on again? Yeah... No problem."
  3. Re:Trendy no more? by subreality · · Score: 4, Informative

    I've used both a fair bit. They are similar in many ways so it's mostly a matter of preference.

    I've found Ruby makes it easy to explore objects and see what can be done with them. The consistent OO model makes it easy to perform concise data manipulation. Here's a quick example:


    irb(main):001:0> arr = ["1", "2", "3", "4"]
    => ["1", "2", "3", "4"]
    irb(main):002:0> arr.methods - Object.methods
    => [:to_a, :to_ary, :[], :[]=, :at, :fetch, :first, :last, :concat, :>>, :push, :pop, :shift, :unshift, :insert, :each, :each_index, :reverse_each, :length, :size, :empty?, :find_index, :index, :rindex, :join, :reverse, :reverse!, :rotate, :rotate!, :sort, :sort!, :sort_by!, :collect, :collect!, :map, :map!, :select, :select!, :keep_if, :values_at, :delete, :delete_at, :delete_if, :reject, :reject!, :zip, :transpose, :replace, :clear, :fill, :slice, :slice!, :assoc, :rassoc, :+, :*, :-, :&, :|, :uniq, :uniq!, :compact, :compact!, :flatten, :flatten!, :count, :shuffle!, :shuffle, :sample, :cycle, :permutation, :combination, :repeated_permutation, :repeated_combination, :product, :take, :take_while, :drop, :drop_while, :bsearch, :pack, :entries, :sort_by, :grep, :find, :detect, :find_all, :flat_map, :collect_concat, :inject, :reduce, :partition, :group_by, :all?, :any?, :one?, :none?, :min, :max, :minmax, :min_by, :max_by, :minmax_by, :member?, :each_with_index, :each_entry, :each_slice, :each_cons, :each_with_object, :chunk, :slice_before, :lazy]
    irb(main):003:0> arr.pop
    => "4"
    irb(main):004:0> arr.join
    => "123"
    irb(main):005:0> arr.map { |i| i.to_i }
    => [1, 2, 3]
    irb(main):006:0> arr.map(&:to_i).reduce(&:+)
    => 6

    Here's the same thing in Python:


    In [1]: arr = ["1", "2", "3", "4"]

    In [2]: dir(arr)
    Out[2]:
    [(stuff removed, fucking lameness filter) 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']

    In [3]: arr.pop()
    Out[3]: '4'

    OK, it's pretty sim