ID:161626
Apr 16 2008, 10:31 am
|
|
I want to make it so there is a prob chance that you will add something to a list when you Login in..
|
Apr 16 2008, 10:35 am
|
|
...then program it? Seriously, that uses an if statement and the prob() function.
|
In response to Popisfizzy
|
|
Well, I figured that much, but I want to know how to add it, so when the the conditions are right it will add it to the list..
|
In response to Lundex
|
|
Look up the "Add proc (list)"
|
In response to Nickr5
|
|
Unless he's adding multiple elements, it's better to use the += operator.
|
In response to Popisfizzy
|
|
No, he was right,the list.Add works..
|
In response to Lundex
|
|
No, Pop was right. :P
Popisfizzy didn't say the Add() proc doesn't work. He just said, and I agree, that if you're only adding one element to a list, you should use the += operator instead of the Add() proc. Since it is an operator, it is more flexible and faster as well. It should be noted though that it's probably still better to use the Add() and Remove() procs if you're adding/removing multiple elements, and you don't already have a list that contains them. Because with the += and -= operators, to work with multiple elements you must create a new list, but in the procs you can just use multiple arguments. |
In response to Popisfizzy
|
|
I agree, the reason I didn't mention it is because looking up the += operator brings up a page that doesn't look relevant to lists.
|
In response to Nickr5
|
|
Well, += is just a shorthand, so you're supposed to look up + itself which mentions list and everything.
Though, actually, perhaps the page should be updated, because with lists- List = List + item Actually do different things, which is commonly overlooked. The latter is like using Add() but the former isn't (look up the + operator to see what it does). Quite commonly people inadvertently use the first expression (List + item) instead, where it isn't needed, but the 2nd method is more efficient and should ideally be used instead. |