Q:

How to create an iterable collection from successive calls to next(), get_Next()

I am starting to use scala and I am trying to convert the following non-functional code into a collection (a lazy one that only retrieves the elements as they are requested):
the non-functional code is:
while (o.next) {
    o.getItem // this will return the "next" element 
}

I tried with this, but it does not work:
val it = Iterator.continually(o. GetItem).takeWhile(_ => o.next)

It looks as if o.next gets called after trying to consume the item, not before.  
Can anybody point me in the right direction?  If I can't make an iterable collection, how do I convert this into a sequence without using a mutable collection? 
thank you very much,

A:

It looks as if o.next gets called after trying to consume the item, not before. 

Yes.  Considering that the predicate function is called on the result of GetItem, GetItem has to be called first. 

Can anybody point me in the right direction?  

Since your object already seems to have equivalents of the two methods required for an iterator, you can just create an iterator for it by calling those methods:
val it = new Iterator[ElementType] {
    def next() = o.getItem()
    def hasNext = o.next
}

