Hello,
Arlen Christian Mart Cuss wrote:
>> and to cut off the first 1/3 and last 1/3 of the array to get about 33
>> elements, shouldn't we use
>>
>> a[0..a.size/2] = a[a.size*2/3..-1] = nil
>
> Or, just do a.slice!(a.size/3..a.size*2/3)
there are so many people who are familiar with Ruby. Have been using
Ruby for a long time? Do you find after using Ruby, a work day becomes
a fun day?
I've been using it for a year or two now -- I'm lucky enough to have a
job where I can choose what language I program in
so, I think a "fun
day" is definitely the way to put it.
To be honest, though, I wasn't even sure a 'slice' or a 'slice!' command
existed when I read your first email. But, I felt the way you stated it
in the start wasn't very "rubyish" enough -- so I looked to see if there
was a way that was - for me - even less surprising. I just opened up
`irb', and then:
irb(main):001:0> a = (1..100).to_a
=> [1, 2, 3, [... removed half of this ...]
irb(main):002:0> a.methods.sort
=> ["&", "*", "+", [... lots of methods ...] "singleton_methods",
"size", "slice", "slice!", "sort", "sort!", [... lots more] "zip", "|"]
irb(main):003:0>
I was looking for something like "slice", and there it is.
So, if you
feel it's a bit tedious, try having a look!
Cheers!
Arlen
···
On Wed, 2007-10-03 at 01:06 +0900, SpringFlowers AutumnMoon wrote: