On 2011-02-06 20:51, Walter Bright wrote:
Jacob Carlborg wrote:
On 2011-02-04 08:34, Jonathan M Davis wrote:
Slices: just one more reason why D's arrays kick the pants of other
languages'
arrays...

- Jonathan M Davis

Ruby has array slices as well. A slice of an array refers to the
original data just like in D. But on the other hand a new instance is
created when making a slice (I assume, since everything is an object
in Ruby).


Can you use an array slice in ruby as an argument to any function that
takes a string?

Since Ruby is a dynamically typed language you can pass in anything you want and relay on duck typing. The object passed in just have to support the slicing syntax/method.

Hm, I just tried this and apparently a slice does NOT behave as in D. Modifying the slice does NOT modify the original array/string, I was completely sure it did.

--
/Jacob Carlborg

Reply via email to