Reassignment to Val

View: New views
14 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Re: Reassignment to Val

by Kevin Wright-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Immutable values can't be changed, ever, this is by design.
It might first look like you cant doing a lot of things, but to see how this idea works it helps to think about the way that numbers behave.

Take the expression "1 + 2": This takes 1, adds 2, and returns a NEW number, 3
In this case, neither 1 nor 2 have changed, you can use them in other parts of your program and they will mean the same thing they always did.

The same idea can be used with lists:
val x = List(2, 3, 4)
val y = 1 :: x

y is now a new list containing 1, 2, 3, 4, the meaning of x is unchanged
(note: it's always better to work at the head of lists for reasons of performance, but that's a different discussion)

I can also say
val z = y map (n => 2 * n)
This now gives me ANOTHER new list, containing 2, 4, 6, 8, once again x and y are unchanged


Thinking like this is one of the core ideas behind functional programming.

If you have good reason to work differently and you want to have a list x that can change but still be called x, then you have two options:
You can use a MutableList, where x is still a val (as it always point to the same, mutable, list), but the contents of that list can now be modified.
Or you can use a var, where x points to an immutable list, but you can exchange that list for another one at any time.

the only real difference is that you can supply a mutable list to a function, and have the function update it for you.  However, it's better design use an immutable list for the function argument, and have it return another NEW immutable list which has the modifications in.


On Tue, Jul 7, 2009 at 5:18 AM, Naftoli Gugenhem <naftoligug@...> wrote:
You always have two choices: either those functions can return relevant information, or they can modify a var that the function and its caller have access to. The first way I believe is more FP, the second more OOP.
By the way scala makes the first easy even when the function has to return multiple values, using tuples or case classes with pattern matching.

-------------------------------------
Joob<travaildereligion@...> wrote:


But what if I have my main calling a function calling another function which
modifies the list,
or any other scenario where the object wouldn't be directly accessible ?

My application goes through the main only once, then loops in another
function that accepts user input to apply various operations to the list, by
calling other operation-specific function such as "add entry" "delete entry"
etc



Daniel Sobral wrote:
>
> Well, if that's possible, yes, that's what you should do.
>
> On Tue, Jul 7, 2009 at 12:59 AM, Joob <travaildereligion@...>
> wrote:
>
>>
>> oh
>> so I should simply return the List and store it ?
>> that does make more sense, come to think of it...
>>
>>
>>
>
>
>

--
View this message in context: http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
Sent from the Scala - User mailing list archive at Nabble.com.



Re: Reassignment to Val

by Joob :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have tried this method, but now I get an error when I try to use a List method on Botin.botin
this is the code :

var tempB = Botin.botin.filter(n => n.individu != tempNom);

The error I get is : value filter is not a member of object List.
If i understand correctly this means that "filter" is not recognized as neither a parameter of botin nor a function that can be applied to a List, which is odd to me since "filter" is a function that can be applied to a List no ?

p.s.: I'm using netbeans at the moment and when I type "Botin.botin." it then shows the possible function calls I can make, I recognize a few from the Scala Library for List such as "apply" but "filter" and a few others are missing.


Daniel Sobral wrote:
You do not need to keep a var with the list. You can just pass the resulting
list back and forth, but, at this point, I don't think that can be taught in
this list. You need to see a lot of functional code to get the idea.
So, instead, I'll suggest something for which many here will condemn me
(seriously!). Put this object somewhere:

object Botin {
  var botin: ... = Nil
}

And then assign the results to Botin.botin. It will fix your immediate
problem, but programming this way will bring you many other problems.

On Tue, Jul 7, 2009 at 1:08 AM, Joob <travaildereligion@hotmail.com> wrote:

>
> But what if I have my main calling a function calling another function
> which
> modifies the list,
> or any other scenario where the object wouldn't be directly accessible ?
>
> My application goes through the main only once, then loops in another
> function that accepts user input to apply various operations to the list,
> by
> calling other operation-specific function such as "add entry" "delete
> entry"
> etc
>
>
>
> Daniel Sobral wrote:
> >
> > Well, if that's possible, yes, that's what you should do.
> >
> > On Tue, Jul 7, 2009 at 12:59 AM, Joob <travaildereligion@hotmail.com>
> > wrote:
> >
> >>
> >> oh
> >> so I should simply return the List and store it ?
> >> that does make more sense, come to think of it...
> >>
> >>
> >>
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
> Sent from the Scala - User mailing list archive at Nabble.com.
>
>


--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews:
review by name, review by reference and review by value.

Re: Reassignment to Val

by Kevin Wright-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We'll need to see some more code (especially the Botin object definition you used). Also what version of scala are you using?

On Thu, Jul 9, 2009 at 4:45 PM, Joob <travaildereligion@...> wrote:

I have tried this method, but now I get an error when I try to use a List
method on Botin.botin
this is the code :

var tempB = Botin.botin.filter(n => n.individu != tempNom);

The error I get is : value filter is not a member of object List.
If i understand correctly this means that "filter" is not recognized as
neither a parameter of botin nor a function that can be applied to a List,
which is odd to me since "filter" is a function that can be applied to a
List no ?

p.s.: I'm using netbeans at the moment and when I type "Botin.botin." it
then shows the possible function calls I can make, I recognize a few from
the Scala Library for List such as "apply" but "filter" and a few others are
missing.



Daniel Sobral wrote:
>
> You do not need to keep a var with the list. You can just pass the
> resulting
> list back and forth, but, at this point, I don't think that can be taught
> in
> this list. You need to see a lot of functional code to get the idea.
> So, instead, I'll suggest something for which many here will condemn me
> (seriously!). Put this object somewhere:
>
> object Botin {
>   var botin: ... = Nil
> }
>
> And then assign the results to Botin.botin. It will fix your immediate
> problem, but programming this way will bring you many other problems.
>
> On Tue, Jul 7, 2009 at 1:08 AM, Joob <travaildereligion@...>
> wrote:
>
>>
>> But what if I have my main calling a function calling another function
>> which
>> modifies the list,
>> or any other scenario where the object wouldn't be directly accessible ?
>>
>> My application goes through the main only once, then loops in another
>> function that accepts user input to apply various operations to the list,
>> by
>> calling other operation-specific function such as "add entry" "delete
>> entry"
>> etc
>>
>>
>>
>> Daniel Sobral wrote:
>> >
>> > Well, if that's possible, yes, that's what you should do.
>> >
>> > On Tue, Jul 7, 2009 at 12:59 AM, Joob <travaildereligion@...>
>> > wrote:
>> >
>> >>
>> >> oh
>> >> so I should simply return the List and store it ?
>> >> that does make more sense, come to think of it...
>> >>
>> >>
>> >>
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
>> Sent from the Scala - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Daniel C. Sobral
>
> Something I learned in academia: there are three kinds of academic
> reviews:
> review by name, review by reference and review by value.
>
>

--
View this message in context: http://www.nabble.com/Reassignment-to-Val-tp24363871p24412446.html
Sent from the Scala - User mailing list archive at Nabble.com.



Re: Reassignment to Val

by Daniel Sobral :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Are you sure you have a Scala List, not a Java one?

On Thu, Jul 9, 2009 at 12:45 PM, Joob <travaildereligion@...> wrote:

I have tried this method, but now I get an error when I try to use a List
method on Botin.botin
this is the code :

var tempB = Botin.botin.filter(n => n.individu != tempNom);

The error I get is : value filter is not a member of object List.
If i understand correctly this means that "filter" is not recognized as
neither a parameter of botin nor a function that can be applied to a List,
which is odd to me since "filter" is a function that can be applied to a
List no ?

p.s.: I'm using netbeans at the moment and when I type "Botin.botin." it
then shows the possible function calls I can make, I recognize a few from
the Scala Library for List such as "apply" but "filter" and a few others are
missing.



Daniel Sobral wrote:
>
> You do not need to keep a var with the list. You can just pass the
> resulting
> list back and forth, but, at this point, I don't think that can be taught
> in
> this list. You need to see a lot of functional code to get the idea.
> So, instead, I'll suggest something for which many here will condemn me
> (seriously!). Put this object somewhere:
>
> object Botin {
>   var botin: ... = Nil
> }
>
> And then assign the results to Botin.botin. It will fix your immediate
> problem, but programming this way will bring you many other problems.
>
> On Tue, Jul 7, 2009 at 1:08 AM, Joob <travaildereligion@...>
> wrote:
>
>>
>> But what if I have my main calling a function calling another function
>> which
>> modifies the list,
>> or any other scenario where the object wouldn't be directly accessible ?
>>
>> My application goes through the main only once, then loops in another
>> function that accepts user input to apply various operations to the list,
>> by
>> calling other operation-specific function such as "add entry" "delete
>> entry"
>> etc
>>
>>
>>
>> Daniel Sobral wrote:
>> >
>> > Well, if that's possible, yes, that's what you should do.
>> >
>> > On Tue, Jul 7, 2009 at 12:59 AM, Joob <travaildereligion@...>
>> > wrote:
>> >
>> >>
>> >> oh
>> >> so I should simply return the List and store it ?
>> >> that does make more sense, come to think of it...
>> >>
>> >>
>> >>
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
>> Sent from the Scala - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Daniel C. Sobral
>
> Something I learned in academia: there are three kinds of academic
> reviews:
> review by name, review by reference and review by value.
>
>

--
View this message in context: http://www.nabble.com/Reassignment-to-Val-tp24363871p24412446.html
Sent from the Scala - User mailing list archive at Nabble.com.




--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.

Re: Reassignment to Val

by Joob :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is how I declared my Botin object

object Botin {
        var botin = List
    }

the version is Scala 2.7.3 (Default)


and also, I thought of this recently, how do I declare the botin list as a list that contains "Adresses",
"Adresses" being a class that I made just for storing a couple of variables together, because when I tried something like

        var tempAdr = new Adresse(tempNom, tempNum, tempRue, tempVille);
        var tempAdreListe = List(tempAdr)
        Botin.botin = tempAdreListe

I got an error saying type mismatch :

found : List[tp2scala.Main.Adresse]
required : object List

I tried the following syntax :

object Botin {
        var botin = List[tp2scala.Main.Adresse]
    }

but I get an error saying:

missing arguments for method apply in object List;
follow this method with `_' if you want to treat it as a partially applied function



Kevin Wright-4 wrote:
We'll need to see some more code (especially the Botin object definition you
used). Also what version of scala are you using?

On Thu, Jul 9, 2009 at 4:45 PM, Joob <travaildereligion@hotmail.com> wrote:

>
> I have tried this method, but now I get an error when I try to use a List
> method on Botin.botin
> this is the code :
>
> var tempB = Botin.botin.filter(n => n.individu != tempNom);
>
> The error I get is : value filter is not a member of object List.
> If i understand correctly this means that "filter" is not recognized as
> neither a parameter of botin nor a function that can be applied to a List,
> which is odd to me since "filter" is a function that can be applied to a
> List no ?
>
> p.s.: I'm using netbeans at the moment and when I type "Botin.botin." it
> then shows the possible function calls I can make, I recognize a few from
> the Scala Library for List such as "apply" but "filter" and a few others
> are
> missing.
>
>
>
> Daniel Sobral wrote:
> >
> > You do not need to keep a var with the list. You can just pass the
> > resulting
> > list back and forth, but, at this point, I don't think that can be taught
> > in
> > this list. You need to see a lot of functional code to get the idea.
> > So, instead, I'll suggest something for which many here will condemn me
> > (seriously!). Put this object somewhere:
> >
> > object Botin {
> >   var botin: ... = Nil
> > }
> >
> > And then assign the results to Botin.botin. It will fix your immediate
> > problem, but programming this way will bring you many other problems.
> >
> > On Tue, Jul 7, 2009 at 1:08 AM, Joob <travaildereligion@hotmail.com>
> > wrote:
> >
> >>
> >> But what if I have my main calling a function calling another function
> >> which
> >> modifies the list,
> >> or any other scenario where the object wouldn't be directly accessible ?
> >>
> >> My application goes through the main only once, then loops in another
> >> function that accepts user input to apply various operations to the
> list,
> >> by
> >> calling other operation-specific function such as "add entry" "delete
> >> entry"
> >> etc
> >>
> >>
> >>
> >> Daniel Sobral wrote:
> >> >
> >> > Well, if that's possible, yes, that's what you should do.
> >> >
> >> > On Tue, Jul 7, 2009 at 12:59 AM, Joob <travaildereligion@hotmail.com>
> >> > wrote:
> >> >
> >> >>
> >> >> oh
> >> >> so I should simply return the List and store it ?
> >> >> that does make more sense, come to think of it...
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
> >> Sent from the Scala - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Daniel C. Sobral
> >
> > Something I learned in academia: there are three kinds of academic
> > reviews:
> > review by name, review by reference and review by value.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Reassignment-to-Val-tp24363871p24412446.html
> Sent from the Scala - User mailing list archive at Nabble.com.
>
>

Parent Message unknown Re: Reassignment to Val

by Naftoli Gugenheim :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The key clue is that "filter is not a member of _object_ List." It's a member of _class_ List. The question is why the compiler is looking in the object and not the class, for which it would help to see your decaration of Botin.botin.



-------------------------------------
Kevin Wright<kev.lee.wright@...> wrote:

We'll need to see some more code (especially the Botin object definition you
used). Also what version of scala are you using?

On Thu, Jul 9, 2009 at 4:45 PM, Joob <travaildereligion@...> wrote:

>
> I have tried this method, but now I get an error when I try to use a List
> method on Botin.botin
> this is the code :
>
> var tempB = Botin.botin.filter(n => n.individu != tempNom);
>
> The error I get is : value filter is not a member of object List.
> If i understand correctly this means that "filter" is not recognized as
> neither a parameter of botin nor a function that can be applied to a List,
> which is odd to me since "filter" is a function that can be applied to a
> List no ?
>
> p.s.: I'm using netbeans at the moment and when I type "Botin.botin." it
> then shows the possible function calls I can make, I recognize a few from
> the Scala Library for List such as "apply" but "filter" and a few others
> are
> missing.
>
>
>
> Daniel Sobral wrote:
> >
> > You do not need to keep a var with the list. You can just pass the
> > resulting
> > list back and forth, but, at this point, I don't think that can be taught
> > in
> > this list. You need to see a lot of functional code to get the idea.
> > So, instead, I'll suggest something for which many here will condemn me
> > (seriously!). Put this object somewhere:
> >
> > object Botin {
> >   var botin: ... = Nil
> > }
> >
> > And then assign the results to Botin.botin. It will fix your immediate
> > problem, but programming this way will bring you many other problems.
> >
> > On Tue, Jul 7, 2009 at 1:08 AM, Joob <travaildereligion@...>
> > wrote:
> >
> >>
> >> But what if I have my main calling a function calling another function
> >> which
> >> modifies the list,
> >> or any other scenario where the object wouldn't be directly accessible ?
> >>
> >> My application goes through the main only once, then loops in another
> >> function that accepts user input to apply various operations to the
> list,
> >> by
> >> calling other operation-specific function such as "add entry" "delete
> >> entry"
> >> etc
> >>
> >>
> >>
> >> Daniel Sobral wrote:
> >> >
> >> > Well, if that's possible, yes, that's what you should do.
> >> >
> >> > On Tue, Jul 7, 2009 at 12:59 AM, Joob <travaildereligion@...>
> >> > wrote:
> >> >
> >> >>
> >> >> oh
> >> >> so I should simply return the List and store it ?
> >> >> that does make more sense, come to think of it...
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
> >> Sent from the Scala - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Daniel C. Sobral
> >
> > Something I learned in academia: there are three kinds of academic
> > reviews:
> > review by name, review by reference and review by value.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Reassignment-to-Val-tp24363871p24412446.html
> Sent from the Scala - User mailing list archive at Nabble.com.
>
>

Re: Reassignment to Val

by Joob :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hmm
How do I check that :o ?

p.s.: I am prepared for various insults and bashing :)


Daniel Sobral wrote:
Are you sure you have a Scala List, not a Java one?

On Thu, Jul 9, 2009 at 12:45 PM, Joob <travaildereligion@hotmail.com> wrote:

>
> I have tried this method, but now I get an error when I try to use a List
> method on Botin.botin
> this is the code :
>
> var tempB = Botin.botin.filter(n => n.individu != tempNom);
>
> The error I get is : value filter is not a member of object List.
> If i understand correctly this means that "filter" is not recognized as
> neither a parameter of botin nor a function that can be applied to a List,
> which is odd to me since "filter" is a function that can be applied to a
> List no ?
>
> p.s.: I'm using netbeans at the moment and when I type "Botin.botin." it
> then shows the possible function calls I can make, I recognize a few from
> the Scala Library for List such as "apply" but "filter" and a few others
> are
> missing.
>
>
>
> Daniel Sobral wrote:
> >
> > You do not need to keep a var with the list. You can just pass the
> > resulting
> > list back and forth, but, at this point, I don't think that can be taught
> > in
> > this list. You need to see a lot of functional code to get the idea.
> > So, instead, I'll suggest something for which many here will condemn me
> > (seriously!). Put this object somewhere:
> >
> > object Botin {
> >   var botin: ... = Nil
> > }
> >
> > And then assign the results to Botin.botin. It will fix your immediate
> > problem, but programming this way will bring you many other problems.
> >
> > On Tue, Jul 7, 2009 at 1:08 AM, Joob <travaildereligion@hotmail.com>
> > wrote:
> >
> >>
> >> But what if I have my main calling a function calling another function
> >> which
> >> modifies the list,
> >> or any other scenario where the object wouldn't be directly accessible ?
> >>
> >> My application goes through the main only once, then loops in another
> >> function that accepts user input to apply various operations to the
> list,
> >> by
> >> calling other operation-specific function such as "add entry" "delete
> >> entry"
> >> etc
> >>
> >>
> >>
> >> Daniel Sobral wrote:
> >> >
> >> > Well, if that's possible, yes, that's what you should do.
> >> >
> >> > On Tue, Jul 7, 2009 at 12:59 AM, Joob <travaildereligion@hotmail.com>
> >> > wrote:
> >> >
> >> >>
> >> >> oh
> >> >> so I should simply return the List and store it ?
> >> >> that does make more sense, come to think of it...
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
> >> Sent from the Scala - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Daniel C. Sobral
> >
> > Something I learned in academia: there are three kinds of academic
> > reviews:
> > review by name, review by reference and review by value.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Reassignment-to-Val-tp24363871p24412446.html
>   Sent from the Scala - User mailing list archive at Nabble.com.
>
>


--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews:
review by name, review by reference and review by value.

Re: Reassignment to Val

by Daniel Sobral :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you use "=", you are assigning a value to the var. If you used ":", then you would be declaring a type (though you'd have to assign a value too). Try this instead:
 
var botin = List.empty[tp2scala.Main.Adresse]
 
Or whatever other type you think it's appropriate for botin.

On Thu, Jul 9, 2009 at 1:35 PM, Joob <travaildereligion@...> wrote:

This is how I declared my Botin object

object Botin {
       var botin = List
   }

the version is Scala 2.7.3 (Default)


and also, I thought of this recently, how do I declare the botin list as a
list that contains "Adresses",
"Adresses" being a class that I made just for storing a couple of variables
together, because when I tried something like

       var tempAdr = new Adresse(tempNom, tempNum, tempRue, tempVille);
       var tempAdreListe = List(tempAdr)
       Botin.botin = tempAdreListe

I got an error saying type mismatch :

found : List[tp2scala.Main.Adresse]
required : object List

I tried the following syntax :

object Botin {
       var botin = List[tp2scala.Main.Adresse]
   }

but I get an error saying:

missing arguments for method apply in object List;
follow this method with `_' if you want to treat it as a partially applied
function




Kevin Wright-4 wrote:
>
> We'll need to see some more code (especially the Botin object definition
> you
> used). Also what version of scala are you using?
>
> On Thu, Jul 9, 2009 at 4:45 PM, Joob <travaildereligion@...>
> wrote:
>
>>
>> I have tried this method, but now I get an error when I try to use a List
>> method on Botin.botin
>> this is the code :
>>
>> var tempB = Botin.botin.filter(n => n.individu != tempNom);
>>
>> The error I get is : value filter is not a member of object List.
>> If i understand correctly this means that "filter" is not recognized as
>> neither a parameter of botin nor a function that can be applied to a
>> List,
>> which is odd to me since "filter" is a function that can be applied to a
>> List no ?
>>
>> p.s.: I'm using netbeans at the moment and when I type "Botin.botin." it
>> then shows the possible function calls I can make, I recognize a few from
>> the Scala Library for List such as "apply" but "filter" and a few others
>> are
>> missing.
>>
>>
>>
>> Daniel Sobral wrote:
>> >
>> > You do not need to keep a var with the list. You can just pass the
>> > resulting
>> > list back and forth, but, at this point, I don't think that can be
>> taught
>> > in
>> > this list. You need to see a lot of functional code to get the idea.
>> > So, instead, I'll suggest something for which many here will condemn me
>> > (seriously!). Put this object somewhere:
>> >
>> > object Botin {
>> >   var botin: ... = Nil
>> > }
>> >
>> > And then assign the results to Botin.botin. It will fix your immediate
>> > problem, but programming this way will bring you many other problems.
>> >
>> > On Tue, Jul 7, 2009 at 1:08 AM, Joob <travaildereligion@...>
>> > wrote:
>> >
>> >>
>> >> But what if I have my main calling a function calling another function
>> >> which
>> >> modifies the list,
>> >> or any other scenario where the object wouldn't be directly accessible
>> ?
>> >>
>> >> My application goes through the main only once, then loops in another
>> >> function that accepts user input to apply various operations to the
>> list,
>> >> by
>> >> calling other operation-specific function such as "add entry" "delete
>> >> entry"
>> >> etc
>> >>
>> >>
>> >>
>> >> Daniel Sobral wrote:
>> >> >
>> >> > Well, if that's possible, yes, that's what you should do.
>> >> >
>> >> > On Tue, Jul 7, 2009 at 12:59 AM, Joob
>> <travaildereligion@...>
>> >> > wrote:
>> >> >
>> >> >>
>> >> >> oh
>> >> >> so I should simply return the List and store it ?
>> >> >> that does make more sense, come to think of it...
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
>> >> Sent from the Scala - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Daniel C. Sobral
>> >
>> > Something I learned in academia: there are three kinds of academic
>> > reviews:
>> > review by name, review by reference and review by value.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Reassignment-to-Val-tp24363871p24412446.html
>> Sent from the Scala - User mailing list archive at Nabble.com.
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Reassignment-to-Val-tp24363871p24413490.html
Sent from the Scala - User mailing list archive at Nabble.com.




--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.

Re: Reassignment to Val

by Joob :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I get a similar error saying that the value "empty" is not a member of object List


Daniel Sobral wrote:
If you use "=", you are assigning a value to the var. If you used ":", then
you would be declaring a type (though you'd have to assign a value too). Try
this instead:

var botin = List.empty[tp2scala.Main.Adresse]

Or whatever other type you think it's appropriate for botin.

On Thu, Jul 9, 2009 at 1:35 PM, Joob <travaildereligion@hotmail.com> wrote:

>
> This is how I declared my Botin object
>
> object Botin {
>        var botin = List
>    }
>
> the version is Scala 2.7.3 (Default)
>
>
> and also, I thought of this recently, how do I declare the botin list as a
> list that contains "Adresses",
> "Adresses" being a class that I made just for storing a couple of variables
> together, because when I tried something like
>
>        var tempAdr = new Adresse(tempNom, tempNum, tempRue, tempVille);
>        var tempAdreListe = List(tempAdr)
>        Botin.botin = tempAdreListe
>
> I got an error saying type mismatch :
>
> found : List[tp2scala.Main.Adresse]
> required : object List
>
> I tried the following syntax :
>
> object Botin {
>        var botin = List[tp2scala.Main.Adresse]
>    }
>
> but I get an error saying:
>
> missing arguments for method apply in object List;
> follow this method with `_' if you want to treat it as a partially applied
> function
>
>
>
>
> Kevin Wright-4 wrote:
> >
> > We'll need to see some more code (especially the Botin object definition
> > you
> > used). Also what version of scala are you using?
> >
> > On Thu, Jul 9, 2009 at 4:45 PM, Joob <travaildereligion@hotmail.com>
> > wrote:
> >
> >>
> >> I have tried this method, but now I get an error when I try to use a
> List
> >> method on Botin.botin
> >> this is the code :
> >>
> >> var tempB = Botin.botin.filter(n => n.individu != tempNom);
> >>
> >> The error I get is : value filter is not a member of object List.
> >> If i understand correctly this means that "filter" is not recognized as
> >> neither a parameter of botin nor a function that can be applied to a
> >> List,
> >> which is odd to me since "filter" is a function that can be applied to a
> >> List no ?
> >>
> >> p.s.: I'm using netbeans at the moment and when I type "Botin.botin." it
> >> then shows the possible function calls I can make, I recognize a few
> from
> >> the Scala Library for List such as "apply" but "filter" and a few others
> >> are
> >> missing.
> >>
> >>
> >>
> >> Daniel Sobral wrote:
> >> >
> >> > You do not need to keep a var with the list. You can just pass the
> >> > resulting
> >> > list back and forth, but, at this point, I don't think that can be
> >> taught
> >> > in
> >> > this list. You need to see a lot of functional code to get the idea.
> >> > So, instead, I'll suggest something for which many here will condemn
> me
> >> > (seriously!). Put this object somewhere:
> >> >
> >> > object Botin {
> >> >   var botin: ... = Nil
> >> > }
> >> >
> >> > And then assign the results to Botin.botin. It will fix your immediate
> >> > problem, but programming this way will bring you many other problems.
> >> >
> >> > On Tue, Jul 7, 2009 at 1:08 AM, Joob <travaildereligion@hotmail.com>
> >> > wrote:
> >> >
> >> >>
> >> >> But what if I have my main calling a function calling another
> function
> >> >> which
> >> >> modifies the list,
> >> >> or any other scenario where the object wouldn't be directly
> accessible
> >> ?
> >> >>
> >> >> My application goes through the main only once, then loops in another
> >> >> function that accepts user input to apply various operations to the
> >> list,
> >> >> by
> >> >> calling other operation-specific function such as "add entry" "delete
> >> >> entry"
> >> >> etc
> >> >>
> >> >>
> >> >>
> >> >> Daniel Sobral wrote:
> >> >> >
> >> >> > Well, if that's possible, yes, that's what you should do.
> >> >> >
> >> >> > On Tue, Jul 7, 2009 at 12:59 AM, Joob
> >> <travaildereligion@hotmail.com>
> >> >> > wrote:
> >> >> >
> >> >> >>
> >> >> >> oh
> >> >> >> so I should simply return the List and store it ?
> >> >> >> that does make more sense, come to think of it...
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
> >> >> Sent from the Scala - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Daniel C. Sobral
> >> >
> >> > Something I learned in academia: there are three kinds of academic
> >> > reviews:
> >> > review by name, review by reference and review by value.
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24412446.html
> >> Sent from the Scala - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Reassignment-to-Val-tp24363871p24413490.html
>   Sent from the Scala - User mailing list archive at Nabble.com.
>
>


--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews:
review by name, review by reference and review by value.

Re: Reassignment to Val

by Daniel Sobral :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I meant to do that instead of "var botin = List". If you did change that, then please post the error message and relevant line.

On Thu, Jul 9, 2009 at 1:49 PM, Joob <travaildereligion@...> wrote:

I get a similar error saying that the value "empty" is not a member of object
List



Daniel Sobral wrote:
>
> If you use "=", you are assigning a value to the var. If you used ":",
> then
> you would be declaring a type (though you'd have to assign a value too).
> Try
> this instead:
>
> var botin = List.empty[tp2scala.Main.Adresse]
>
> Or whatever other type you think it's appropriate for botin.
>
> On Thu, Jul 9, 2009 at 1:35 PM, Joob <travaildereligion@...>
> wrote:
>
>>
>> This is how I declared my Botin object
>>
>> object Botin {
>>        var botin = List
>>    }
>>
>> the version is Scala 2.7.3 (Default)
>>
>>
>> and also, I thought of this recently, how do I declare the botin list as
>> a
>> list that contains "Adresses",
>> "Adresses" being a class that I made just for storing a couple of
>> variables
>> together, because when I tried something like
>>
>>        var tempAdr = new Adresse(tempNom, tempNum, tempRue, tempVille);
>>        var tempAdreListe = List(tempAdr)
>>        Botin.botin = tempAdreListe
>>
>> I got an error saying type mismatch :
>>
>> found : List[tp2scala.Main.Adresse]
>> required : object List
>>
>> I tried the following syntax :
>>
>> object Botin {
>>        var botin = List[tp2scala.Main.Adresse]
>>    }
>>
>> but I get an error saying:
>>
>> missing arguments for method apply in object List;
>> follow this method with `_' if you want to treat it as a partially
>> applied
>> function
>>
>>
>>
>>
>> Kevin Wright-4 wrote:
>> >
>> > We'll need to see some more code (especially the Botin object
>> definition
>> > you
>> > used). Also what version of scala are you using?
>> >
>> > On Thu, Jul 9, 2009 at 4:45 PM, Joob <travaildereligion@...>
>> > wrote:
>> >
>> >>
>> >> I have tried this method, but now I get an error when I try to use a
>> List
>> >> method on Botin.botin
>> >> this is the code :
>> >>
>> >> var tempB = Botin.botin.filter(n => n.individu != tempNom);
>> >>
>> >> The error I get is : value filter is not a member of object List.
>> >> If i understand correctly this means that "filter" is not recognized
>> as
>> >> neither a parameter of botin nor a function that can be applied to a
>> >> List,
>> >> which is odd to me since "filter" is a function that can be applied to
>> a
>> >> List no ?
>> >>
>> >> p.s.: I'm using netbeans at the moment and when I type "Botin.botin."
>> it
>> >> then shows the possible function calls I can make, I recognize a few
>> from
>> >> the Scala Library for List such as "apply" but "filter" and a few
>> others
>> >> are
>> >> missing.
>> >>
>> >>
>> >>
>> >> Daniel Sobral wrote:
>> >> >
>> >> > You do not need to keep a var with the list. You can just pass the
>> >> > resulting
>> >> > list back and forth, but, at this point, I don't think that can be
>> >> taught
>> >> > in
>> >> > this list. You need to see a lot of functional code to get the idea.
>> >> > So, instead, I'll suggest something for which many here will condemn
>> me
>> >> > (seriously!). Put this object somewhere:
>> >> >
>> >> > object Botin {
>> >> >   var botin: ... = Nil
>> >> > }
>> >> >
>> >> > And then assign the results to Botin.botin. It will fix your
>> immediate
>> >> > problem, but programming this way will bring you many other
>> problems.
>> >> >
>> >> > On Tue, Jul 7, 2009 at 1:08 AM, Joob <travaildereligion@...>
>> >> > wrote:
>> >> >
>> >> >>
>> >> >> But what if I have my main calling a function calling another
>> function
>> >> >> which
>> >> >> modifies the list,
>> >> >> or any other scenario where the object wouldn't be directly
>> accessible
>> >> ?
>> >> >>
>> >> >> My application goes through the main only once, then loops in
>> another
>> >> >> function that accepts user input to apply various operations to the
>> >> list,
>> >> >> by
>> >> >> calling other operation-specific function such as "add entry"
>> "delete
>> >> >> entry"
>> >> >> etc
>> >> >>
>> >> >>
>> >> >>
>> >> >> Daniel Sobral wrote:
>> >> >> >
>> >> >> > Well, if that's possible, yes, that's what you should do.
>> >> >> >
>> >> >> > On Tue, Jul 7, 2009 at 12:59 AM, Joob
>> >> <travaildereligion@...>
>> >> >> > wrote:
>> >> >> >
>> >> >> >>
>> >> >> >> oh
>> >> >> >> so I should simply return the List and store it ?
>> >> >> >> that does make more sense, come to think of it...
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
>> >> >> Sent from the Scala - User mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Daniel C. Sobral
>> >> >
>> >> > Something I learned in academia: there are three kinds of academic
>> >> > reviews:
>> >> > review by name, review by reference and review by value.
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24412446.html
>> >> Sent from the Scala - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Reassignment-to-Val-tp24363871p24413490.html
>>   Sent from the Scala - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Daniel C. Sobral
>
> Something I learned in academia: there are three kinds of academic
> reviews:
> review by name, review by reference and review by value.
>
>

--
View this message in context: http://www.nabble.com/Reassignment-to-Val-tp24363871p24413774.html
Sent from the Scala - User mailing list archive at Nabble.com.




--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.

Re: Reassignment to Val

by Joob :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

    object Botin {
        var botin = List.empty[tp2scala.Main.Adresse]                                    <--- Error Line
    }

error msg :

value empty is not a member of object List


Daniel Sobral wrote:
I meant to do that instead of "var botin = List". If you did change that,
then please post the error message and relevant line.

On Thu, Jul 9, 2009 at 1:49 PM, Joob <travaildereligion@hotmail.com> wrote:

>
> I get a similar error saying that the value "empty" is not a member of
> object
> List
>
>
>
> Daniel Sobral wrote:
> >
> > If you use "=", you are assigning a value to the var. If you used ":",
> > then
> > you would be declaring a type (though you'd have to assign a value too).
> > Try
> > this instead:
> >
> > var botin = List.empty[tp2scala.Main.Adresse]
> >
> > Or whatever other type you think it's appropriate for botin.
> >
> > On Thu, Jul 9, 2009 at 1:35 PM, Joob <travaildereligion@hotmail.com>
> > wrote:
> >
> >>
> >> This is how I declared my Botin object
> >>
> >> object Botin {
> >>        var botin = List
> >>    }
> >>
> >> the version is Scala 2.7.3 (Default)
> >>
> >>
> >> and also, I thought of this recently, how do I declare the botin list as
> >> a
> >> list that contains "Adresses",
> >> "Adresses" being a class that I made just for storing a couple of
> >> variables
> >> together, because when I tried something like
> >>
> >>        var tempAdr = new Adresse(tempNom, tempNum, tempRue, tempVille);
> >>        var tempAdreListe = List(tempAdr)
> >>        Botin.botin = tempAdreListe
> >>
> >> I got an error saying type mismatch :
> >>
> >> found : List[tp2scala.Main.Adresse]
> >> required : object List
> >>
> >> I tried the following syntax :
> >>
> >> object Botin {
> >>        var botin = List[tp2scala.Main.Adresse]
> >>    }
> >>
> >> but I get an error saying:
> >>
> >> missing arguments for method apply in object List;
> >> follow this method with `_' if you want to treat it as a partially
> >> applied
> >> function
> >>
> >>
> >>
> >>
> >> Kevin Wright-4 wrote:
> >> >
> >> > We'll need to see some more code (especially the Botin object
> >> definition
> >> > you
> >> > used). Also what version of scala are you using?
> >> >
> >> > On Thu, Jul 9, 2009 at 4:45 PM, Joob <travaildereligion@hotmail.com>
> >> > wrote:
> >> >
> >> >>
> >> >> I have tried this method, but now I get an error when I try to use a
> >> List
> >> >> method on Botin.botin
> >> >> this is the code :
> >> >>
> >> >> var tempB = Botin.botin.filter(n => n.individu != tempNom);
> >> >>
> >> >> The error I get is : value filter is not a member of object List.
> >> >> If i understand correctly this means that "filter" is not recognized
> >> as
> >> >> neither a parameter of botin nor a function that can be applied to a
> >> >> List,
> >> >> which is odd to me since "filter" is a function that can be applied
> to
> >> a
> >> >> List no ?
> >> >>
> >> >> p.s.: I'm using netbeans at the moment and when I type "Botin.botin."
> >> it
> >> >> then shows the possible function calls I can make, I recognize a few
> >> from
> >> >> the Scala Library for List such as "apply" but "filter" and a few
> >> others
> >> >> are
> >> >> missing.
> >> >>
> >> >>
> >> >>
> >> >> Daniel Sobral wrote:
> >> >> >
> >> >> > You do not need to keep a var with the list. You can just pass the
> >> >> > resulting
> >> >> > list back and forth, but, at this point, I don't think that can be
> >> >> taught
> >> >> > in
> >> >> > this list. You need to see a lot of functional code to get the
> idea.
> >> >> > So, instead, I'll suggest something for which many here will
> condemn
> >> me
> >> >> > (seriously!). Put this object somewhere:
> >> >> >
> >> >> > object Botin {
> >> >> >   var botin: ... = Nil
> >> >> > }
> >> >> >
> >> >> > And then assign the results to Botin.botin. It will fix your
> >> immediate
> >> >> > problem, but programming this way will bring you many other
> >> problems.
> >> >> >
> >> >> > On Tue, Jul 7, 2009 at 1:08 AM, Joob <
> travaildereligion@hotmail.com>
> >> >> > wrote:
> >> >> >
> >> >> >>
> >> >> >> But what if I have my main calling a function calling another
> >> function
> >> >> >> which
> >> >> >> modifies the list,
> >> >> >> or any other scenario where the object wouldn't be directly
> >> accessible
> >> >> ?
> >> >> >>
> >> >> >> My application goes through the main only once, then loops in
> >> another
> >> >> >> function that accepts user input to apply various operations to
> the
> >> >> list,
> >> >> >> by
> >> >> >> calling other operation-specific function such as "add entry"
> >> "delete
> >> >> >> entry"
> >> >> >> etc
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> Daniel Sobral wrote:
> >> >> >> >
> >> >> >> > Well, if that's possible, yes, that's what you should do.
> >> >> >> >
> >> >> >> > On Tue, Jul 7, 2009 at 12:59 AM, Joob
> >> >> <travaildereligion@hotmail.com>
> >> >> >> > wrote:
> >> >> >> >
> >> >> >> >>
> >> >> >> >> oh
> >> >> >> >> so I should simply return the List and store it ?
> >> >> >> >> that does make more sense, come to think of it...
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >> >> --
> >> >> >> View this message in context:
> >> >> >>
> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
> >> >> >> Sent from the Scala - User mailing list archive at Nabble.com.
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Daniel C. Sobral
> >> >> >
> >> >> > Something I learned in academia: there are three kinds of academic
> >> >> > reviews:
> >> >> > review by name, review by reference and review by value.
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24412446.html
> >> >> Sent from the Scala - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24413490.html
> >>   Sent from the Scala - User mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Daniel C. Sobral
> >
> > Something I learned in academia: there are three kinds of academic
> > reviews:
> > review by name, review by reference and review by value.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Reassignment-to-Val-tp24363871p24413774.html
>   Sent from the Scala - User mailing list archive at Nabble.com.
>
>


--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews:
review by name, review by reference and review by value.

Re: Reassignment to Val

by Daniel Sobral :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mmmm. You have "List" defined somewhere as something other than the class. Ok, replace that with:

var botin = _root_.scala.List.empty[tp2scala.Main.Adresse]
On Thu, Jul 9, 2009 at 1:56 PM, Joob <travaildereligion@...> wrote:

   object Botin {
       var botin = List.empty[tp2scala.Main.Adresse]
<--- Error Line
   }

error msg :

value empty is not a member of object List



Daniel Sobral wrote:
>
> I meant to do that instead of "var botin = List". If you did change that,
> then please post the error message and relevant line.
>
> On Thu, Jul 9, 2009 at 1:49 PM, Joob <travaildereligion@...>
> wrote:
>
>>
>> I get a similar error saying that the value "empty" is not a member of
>> object
>> List
>>
>>
>>
>> Daniel Sobral wrote:
>> >
>> > If you use "=", you are assigning a value to the var. If you used ":",
>> > then
>> > you would be declaring a type (though you'd have to assign a value
>> too).
>> > Try
>> > this instead:
>> >
>> > var botin = List.empty[tp2scala.Main.Adresse]
>> >
>> > Or whatever other type you think it's appropriate for botin.
>> >
>> > On Thu, Jul 9, 2009 at 1:35 PM, Joob <travaildereligion@...>
>> > wrote:
>> >
>> >>
>> >> This is how I declared my Botin object
>> >>
>> >> object Botin {
>> >>        var botin = List
>> >>    }
>> >>
>> >> the version is Scala 2.7.3 (Default)
>> >>
>> >>
>> >> and also, I thought of this recently, how do I declare the botin list
>> as
>> >> a
>> >> list that contains "Adresses",
>> >> "Adresses" being a class that I made just for storing a couple of
>> >> variables
>> >> together, because when I tried something like
>> >>
>> >>        var tempAdr = new Adresse(tempNom, tempNum, tempRue,
>> tempVille);
>> >>        var tempAdreListe = List(tempAdr)
>> >>        Botin.botin = tempAdreListe
>> >>
>> >> I got an error saying type mismatch :
>> >>
>> >> found : List[tp2scala.Main.Adresse]
>> >> required : object List
>> >>
>> >> I tried the following syntax :
>> >>
>> >> object Botin {
>> >>        var botin = List[tp2scala.Main.Adresse]
>> >>    }
>> >>
>> >> but I get an error saying:
>> >>
>> >> missing arguments for method apply in object List;
>> >> follow this method with `_' if you want to treat it as a partially
>> >> applied
>> >> function
>> >>
>> >>
>> >>
>> >>
>> >> Kevin Wright-4 wrote:
>> >> >
>> >> > We'll need to see some more code (especially the Botin object
>> >> definition
>> >> > you
>> >> > used). Also what version of scala are you using?
>> >> >
>> >> > On Thu, Jul 9, 2009 at 4:45 PM, Joob <travaildereligion@...>
>> >> > wrote:
>> >> >
>> >> >>
>> >> >> I have tried this method, but now I get an error when I try to use
>> a
>> >> List
>> >> >> method on Botin.botin
>> >> >> this is the code :
>> >> >>
>> >> >> var tempB = Botin.botin.filter(n => n.individu != tempNom);
>> >> >>
>> >> >> The error I get is : value filter is not a member of object List.
>> >> >> If i understand correctly this means that "filter" is not
>> recognized
>> >> as
>> >> >> neither a parameter of botin nor a function that can be applied to
>> a
>> >> >> List,
>> >> >> which is odd to me since "filter" is a function that can be applied
>> to
>> >> a
>> >> >> List no ?
>> >> >>
>> >> >> p.s.: I'm using netbeans at the moment and when I type
>> "Botin.botin."
>> >> it
>> >> >> then shows the possible function calls I can make, I recognize a
>> few
>> >> from
>> >> >> the Scala Library for List such as "apply" but "filter" and a few
>> >> others
>> >> >> are
>> >> >> missing.
>> >> >>
>> >> >>
>> >> >>
>> >> >> Daniel Sobral wrote:
>> >> >> >
>> >> >> > You do not need to keep a var with the list. You can just pass
>> the
>> >> >> > resulting
>> >> >> > list back and forth, but, at this point, I don't think that can
>> be
>> >> >> taught
>> >> >> > in
>> >> >> > this list. You need to see a lot of functional code to get the
>> idea.
>> >> >> > So, instead, I'll suggest something for which many here will
>> condemn
>> >> me
>> >> >> > (seriously!). Put this object somewhere:
>> >> >> >
>> >> >> > object Botin {
>> >> >> >   var botin: ... = Nil
>> >> >> > }
>> >> >> >
>> >> >> > And then assign the results to Botin.botin. It will fix your
>> >> immediate
>> >> >> > problem, but programming this way will bring you many other
>> >> problems.
>> >> >> >
>> >> >> > On Tue, Jul 7, 2009 at 1:08 AM, Joob <
>> travaildereligion@...>
>> >> >> > wrote:
>> >> >> >
>> >> >> >>
>> >> >> >> But what if I have my main calling a function calling another
>> >> function
>> >> >> >> which
>> >> >> >> modifies the list,
>> >> >> >> or any other scenario where the object wouldn't be directly
>> >> accessible
>> >> >> ?
>> >> >> >>
>> >> >> >> My application goes through the main only once, then loops in
>> >> another
>> >> >> >> function that accepts user input to apply various operations to
>> the
>> >> >> list,
>> >> >> >> by
>> >> >> >> calling other operation-specific function such as "add entry"
>> >> "delete
>> >> >> >> entry"
>> >> >> >> etc
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> Daniel Sobral wrote:
>> >> >> >> >
>> >> >> >> > Well, if that's possible, yes, that's what you should do.
>> >> >> >> >
>> >> >> >> > On Tue, Jul 7, 2009 at 12:59 AM, Joob
>> >> >> <travaildereligion@...>
>> >> >> >> > wrote:
>> >> >> >> >
>> >> >> >> >>
>> >> >> >> >> oh
>> >> >> >> >> so I should simply return the List and store it ?
>> >> >> >> >> that does make more sense, come to think of it...
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >>
>> >> >> >> --
>> >> >> >> View this message in context:
>> >> >> >>
>> http://www.nabble.com/Reassignment-to-Val-tp24363871p24366861.html
>> >> >> >> Sent from the Scala - User mailing list archive at Nabble.com.
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> > Daniel C. Sobral
>> >> >> >
>> >> >> > Something I learned in academia: there are three kinds of
>> academic
>> >> >> > reviews:
>> >> >> > review by name, review by reference and review by value.
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24412446.html
>> >> >> Sent from the Scala - User mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Reassignment-to-Val-tp24363871p24413490.html
>> >>   Sent from the Scala - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Daniel C. Sobral
>> >
>> > Something I learned in academia: there are three kinds of academic
>> > reviews:
>> > review by name, review by reference and review by value.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Reassignment-to-Val-tp24363871p24413774.html
>>   Sent from the Scala - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Daniel C. Sobral
>
> Something I learned in academia: there are three kinds of academic
> reviews:
> review by name, review by reference and review by value.
>
>

--
View this message in context: http://www.nabble.com/Reassignment-to-Val-tp24363871p24413969.html
Sent from the Scala - User mailing list archive at Nabble.com.




--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.

Re: Reassignment to Val

by Randall Schulz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday July 9 2009, Daniel Sobral wrote:
> If you use "=", you are assigning a value to the var. If you used
> ":", then you would be declaring a type (though you'd have to assign
> a value too). Try this instead:
>
> var botin = List.empty[tp2scala.Main.Adresse]

It's probably a good idea to check if you're referring to 2.8-specific
classes or methods. The "empty" method in object List is a 2.8 thing.


> Or whatever other type you think it's appropriate for botin.


Randall Schulz

Re: Reassignment to Val

by Daniel Sobral :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I usually do, but it so happens that this time I didn't. I apologize, Joob. Use one of the following instead:
 
var botin = List[tp2scala.Main.Adresse]()
or
var botin = Nil[tp2scala.main.Adresse]

On Thu, Jul 9, 2009 at 3:03 PM, Randall R Schulz <rschulz@...> wrote:
On Thursday July 9 2009, Daniel Sobral wrote:
> If you use "=", you are assigning a value to the var. If you used
> ":", then you would be declaring a type (though you'd have to assign
> a value too). Try this instead:
>
> var botin = List.empty[tp2scala.Main.Adresse]

It's probably a good idea to check if you're referring to 2.8-specific
classes or methods. The "empty" method in object List is a 2.8 thing.


> Or whatever other type you think it's appropriate for botin.


Randall Schulz



--
Daniel C. Sobral

Something I learned in academia: there are three kinds of academic reviews: review by name, review by reference and review by value.
< Prev | 1 - 2 | Next >