[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

array ending syntax question

Roger Pack

7/15/2008 5:13:00 AM

irb(main):001:0> [1,2][2..2]
=> []
irb(main):002:0> [1,2][3..3]
=> nil


Is this expected?
the ri says:
Returns nil if the index (or starting index) are out of range.

does the first example match this?
Thanks!
-R
--
Posted via http://www.ruby-....

7 Answers

fedzor

7/15/2008 1:59:00 PM

0


On Jul 15, 2008, at 1:13 AM, Roger Pack wrote:

> irb(main):001:0> [1,2][2..2]
> => []
> irb(main):002:0> [1,2][3..3]
> => nil
>
>
> Is this expected?
> the ri says:
> Returns nil if the index (or starting index) are out of range.
>
> does the first example match this?

Yes, because array indices start at 0. So the highest index in the
example is 1.

-------------------------------------------------------|
~ Ari
Some people want love
Others want money
Me... Well...
I just want this code to compile


Alex Gutteridge

7/15/2008 2:08:00 PM

0

On 15 Jul 2008, at 06:13, Roger Pack wrote:

> irb(main):001:0> [1,2][2..2]
> => []
> irb(main):002:0> [1,2][3..3]
> => nil
>
>
> Is this expected?
> the ri says:
> Returns nil if the index (or starting index) are out of range.
>
> does the first example match this?
> Thanks!
> -R

From the Pickaxe: If the start index equals the array size and a
length or range (as here) parameter is given, an empty array is
returned.

Not sure why you would want that behaviour though...

Alex Gutteridge

Department of Biochemistry
University of Cambridge





Frederick Cheung

7/15/2008 4:52:00 PM

0


On 15 Jul 2008, at 15:07, Alex Gutteridge wrote:

> On 15 Jul 2008, at 06:13, Roger Pack wrote:
>
>> irb(main):001:0> [1,2][2..2]
>> => []
>> irb(main):002:0> [1,2][3..3]
>> => nil
>>
>>
>> Is this expected?
>> the ri says:
>> Returns nil if the index (or starting index) are out of range.
>>
>> does the first example match this?
>> Thanks!
>> -R
>
> From the Pickaxe: If the start index equals the array size and a
> length or range (as here) parameter is given, an empty array is
> returned.
>
> Not sure why you would want that behaviour though...


It sort of makes sense in that in an n item array n is actually a
useful index - it's where the next item will go.

Fred

John Doe

5/4/2014 1:29:00 PM

0

On Sat, 03 May 2014 11:15:40 -0700, MattB <trdell12345@gmail.com>
wrote:

>On Sat, 03 May 2014 10:42:18 -0400, NoBody <NoBody@nowhere.com> wrote:
>
>>On Fri, 02 May 2014 21:12:20 -0700, MattB <trdell12345@gmail.com>
>>wrote:
>>
>>>Seattle mayor says he struck a deal for a $15 minimum wage
>>>
>>>http://www.washingtonpost.com/blogs/govbeat/wp/2014/05/01/seattle-mayor-says-he-struck-a-deal-for-a-15-min...
>>>
>>>Seattle Mayor Ed Murray announced plans Thursday to increase the
>>>minimum wage to $15 there, which would place it among of the highest
>>>in the nation.
>>>
>>>The plan would give businesses with fewer than 500 employees seven
>>>years to comply and larger businesses three years. Further increases
>>>would be tied to inflation.
>>>
>>
>>So the minimum wage crisis will become that much larger when suddenly
>>many more people earn only minimum wage. After all, the rest of us
>>won't get equal raises will we?
>
>
>Think there will be pressure for getting those increases. The lowest
>paid worker where I work makes $18.25 HR plus benefits. I can see
>that wage going up. Would think it would depend of the skill level
>or training cost and such.

You can think that all you want but it doesn't make it so. Many
companies have frozen worker's wages for years now. Do you think they
will suddenly have a change of heart?

MattB .

5/4/2014 4:57:00 PM

0

On Sun, 04 May 2014 09:29:16 -0400, NoBody <NoBody@nowhere.com> wrote:

>On Sat, 03 May 2014 11:15:40 -0700, MattB <trdell12345@gmail.com>
>wrote:
>
>>On Sat, 03 May 2014 10:42:18 -0400, NoBody <NoBody@nowhere.com> wrote:
>>
>>>On Fri, 02 May 2014 21:12:20 -0700, MattB <trdell12345@gmail.com>
>>>wrote:
>>>
>>>>Seattle mayor says he struck a deal for a $15 minimum wage
>>>>
>>>>http://www.washingtonpost.com/blogs/govbeat/wp/2014/05/01/seattle-mayor-says-he-struck-a-deal-for-a-15-min...
>>>>
>>>>Seattle Mayor Ed Murray announced plans Thursday to increase the
>>>>minimum wage to $15 there, which would place it among of the highest
>>>>in the nation.
>>>>
>>>>The plan would give businesses with fewer than 500 employees seven
>>>>years to comply and larger businesses three years. Further increases
>>>>would be tied to inflation.
>>>>
>>>
>>>So the minimum wage crisis will become that much larger when suddenly
>>>many more people earn only minimum wage. After all, the rest of us
>>>won't get equal raises will we?
>>
>>
>>Think there will be pressure for getting those increases. The lowest
>>paid worker where I work makes $18.25 HR plus benefits. I can see
>>that wage going up. Would think it would depend of the skill level
>>or training cost and such.
>
>You can think that all you want but it doesn't make it so. Many
>companies have frozen worker's wages for years now. Do you think they
>will suddenly have a change of heart?

Depends on the company. There are many companies wall street does not
control. Most will just pass on any cost to consumers.

John Doe

5/5/2014 10:42:00 AM

0

On Sun, 04 May 2014 09:57:07 -0700, MattB <trdell12345@gmail.com>
wrote:

>On Sun, 04 May 2014 09:29:16 -0400, NoBody <NoBody@nowhere.com> wrote:
>
>>On Sat, 03 May 2014 11:15:40 -0700, MattB <trdell12345@gmail.com>
>>wrote:
>>
>>>On Sat, 03 May 2014 10:42:18 -0400, NoBody <NoBody@nowhere.com> wrote:
>>>
>>>>On Fri, 02 May 2014 21:12:20 -0700, MattB <trdell12345@gmail.com>
>>>>wrote:
>>>>
>>>>>Seattle mayor says he struck a deal for a $15 minimum wage
>>>>>
>>>>>http://www.washingtonpost.com/blogs/govbeat/wp/2014/05/01/seattle-mayor-says-he-struck-a-deal-for-a-15-min...
>>>>>
>>>>>Seattle Mayor Ed Murray announced plans Thursday to increase the
>>>>>minimum wage to $15 there, which would place it among of the highest
>>>>>in the nation.
>>>>>
>>>>>The plan would give businesses with fewer than 500 employees seven
>>>>>years to comply and larger businesses three years. Further increases
>>>>>would be tied to inflation.
>>>>>
>>>>
>>>>So the minimum wage crisis will become that much larger when suddenly
>>>>many more people earn only minimum wage. After all, the rest of us
>>>>won't get equal raises will we?
>>>
>>>
>>>Think there will be pressure for getting those increases. The lowest
>>>paid worker where I work makes $18.25 HR plus benefits. I can see
>>>that wage going up. Would think it would depend of the skill level
>>>or training cost and such.
>>
>>You can think that all you want but it doesn't make it so. Many
>>companies have frozen worker's wages for years now. Do you think they
>>will suddenly have a change of heart?
>
>Depends on the company. There are many companies wall street does not
>control. Most will just pass on any cost to consumers.

Some will provide increases but I suspect that few will do so. If you
have any evidence that companies will do this, feel free to provide
it.

MattB .

5/5/2014 5:18:00 PM

0

On Mon, 05 May 2014 06:42:13 -0400, NoBody <NoBody@nowhere.com> wrote:

>On Sun, 04 May 2014 09:57:07 -0700, MattB <trdell12345@gmail.com>
>wrote:
>
>>On Sun, 04 May 2014 09:29:16 -0400, NoBody <NoBody@nowhere.com> wrote:
>>
>>>On Sat, 03 May 2014 11:15:40 -0700, MattB <trdell12345@gmail.com>
>>>wrote:
>>>
>>>>On Sat, 03 May 2014 10:42:18 -0400, NoBody <NoBody@nowhere.com> wrote:
>>>>
>>>>>On Fri, 02 May 2014 21:12:20 -0700, MattB <trdell12345@gmail.com>
>>>>>wrote:
>>>>>
>>>>>>Seattle mayor says he struck a deal for a $15 minimum wage
>>>>>>
>>>>>>http://www.washingtonpost.com/blogs/govbeat/wp/2014/05/01/seattle-mayor-says-he-struck-a-deal-for-a-15-min...
>>>>>>
>>>>>>Seattle Mayor Ed Murray announced plans Thursday to increase the
>>>>>>minimum wage to $15 there, which would place it among of the highest
>>>>>>in the nation.
>>>>>>
>>>>>>The plan would give businesses with fewer than 500 employees seven
>>>>>>years to comply and larger businesses three years. Further increases
>>>>>>would be tied to inflation.
>>>>>>
>>>>>
>>>>>So the minimum wage crisis will become that much larger when suddenly
>>>>>many more people earn only minimum wage. After all, the rest of us
>>>>>won't get equal raises will we?
>>>>
>>>>
>>>>Think there will be pressure for getting those increases. The lowest
>>>>paid worker where I work makes $18.25 HR plus benefits. I can see
>>>>that wage going up. Would think it would depend of the skill level
>>>>or training cost and such.
>>>
>>>You can think that all you want but it doesn't make it so. Many
>>>companies have frozen worker's wages for years now. Do you think they
>>>will suddenly have a change of heart?
>>
>>Depends on the company. There are many companies wall street does not
>>control. Most will just pass on any cost to consumers.
>
>Some will provide increases but I suspect that few will do so. If you
>have any evidence that companies will do this, feel free to provide
>it.


Not on a wide basis no. Then it would also depend on if the services
provided are specialized. What I am saying is some will but those
that take little training won't.

Prices will go up.

What I am wondering is what will happen with this and when Obamacare
employer mandate goes into effect. How much will that increase cost
and prices.

Little I've read don't think it will have much effect on wages for a
time in Seattle. Most the major companies aren't in Seattle.