# Re: Ruby and WMI

**URL:** <https://www.ruby-forum.com/t/re-ruby-and-wmi/48567>\
**Category:** Ruby\
**Created:** [November 22, 2005, 7:54am UTC](https://www.ruby-forum.com/t/re-ruby-and-wmi/48567 "2005-11-22T07:54:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/258eb7/32.png) [@botp](https://www.ruby-forum.com/u/botp)\
**Post date:** [November 22, 2005, 7:54am UTC](https://www.ruby-forum.com/t/re-ruby-and-wmi/48567/1 "2005-11-22T07:54:29Z")

</div>

#Thank you, it now works, can you tell me one thing, ( I am learning)  
#what does [8…-1] mean in the script “puts “\t” + mem.adsPath[8…-1]”.

hope this is simple enough.

C:\family\ruby\>irb --simple-prompt

> > x=[0,1,2,3,4,5]  
> > =\> [0, 1, 2, 3, 4, 5]

here, we access normally the array x.  
the first index starts at 0.

> > x[0…1]  
> > =\> [0, 1]

we access the third (3-1) and fifth element (5-1)

> > x[2…4]  
> > =\> [2, 3, 4]

to access the element relative to the last position, prefix the index  
with a minus sign. But there is -0, so start w -1.

> > x[2…-1]  
> > =\> [2, 3, 4, 5]

> > x[2…-2]  
> > =\> [2, 3, 4]

it works too even if both are negative as long as start index is less  
than or equal to ending index

> > x[-4…-1]  
> > =\> [2, 3, 4, 5]

> > x[-2…-1]  
> > =\> [4, 5]

> > x[-1…-1]  
> > =\> [5]

> > x[-4…-4]  
> > =\> [2]

otherwise, these will return empty arrays

> > x[-1…2]  
> > =\> []

> > x[-1…-5]  
> > =\> []

> > x[-1…-4]  
> > =\> []

hth.

kind regards -botp
