|
sstanko78 wrote:
Public ReadOnly Property GetChallengedCardList() As ArrayList
Get
Return _challengedCardList
End Get
End Property
Isn't that mutable? You shouldn't return the whole array as it could then be changed from /outside/. Then puppy's cry.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hey,
I'm used to returning the whole array, and I know that it then can be muted, but dno how to prevent this. Could you give an example of how it should be done?
Cheers
BN
|
|
|
|
|
AFAIK you have to clone the array.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
dan neely wrote: AFAIK you have to clone the array.
No, just wrap it:
System.Collections.Generic.List<string> mutable = new List<string>();
System.Collections.ObjectModel.ReadOnlyCollection<string> immutable = mutable.AsReadOnly();
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Does that work with normal arrays as well as List<>'s?
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Do I look like I know!
I was going to flippently say for usre, but I am unable to find it.
In Java the base Collection supports immutable references, too late of evening for me to look, and so that goes through all the Map and Set classes. It seems a sensible approach; just not for M$.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
OK. Until recently I've been doing 1.1 framework stuff , and was wondering if this was an new feature or something I'd managed to not discover in several years of using the language.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Thnx dude, didn't know that
GSoC 2009 student for SMW!
---
My little forums: http://code.bn2vs.com
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
Not a coding horror as such, but I fondly remember being given a 250 page software specification which ended
"Then a miracle occurs"
Cheers Phil!
|
|
|
|
|
|
Bed Time Story:
Once up on a time, there was
OriginalGriff wrote: 250 page software specification
who lived on paper happily, then it got transferred to code and ...
OriginalGriff wrote: "Then a miracle occurs"
The End!
Good Night
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
No, that's not a horror. That is someone giving stating what really needs to happen in order for the project to work.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
If the worst horror you could find in my company is ranked 10 and a moderate horror is ranked 1, I think I could rank this with 5:
Dim key As String
key= "N"
key= "linatipedi=" + "'" + key+ "'"
Dim rR As DataRow() = t.Select(key)
If rR.Length() = 0 Then
i = 0
Else
Try
For Each r In rR
i += 1
Next r
Catch
If i = 0 Then
Return True
Else
Return False
End If
End Try
End If
If i = 0 Then
Return True
Else
Return False
End If
|
|
|
|
|
adgonz wrote: I think I could rank this with 5
That is because VB's scale starts at 5
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 2 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
so one couldn't do any better in VB?
|
|
|
|
|
C#:
string[] codes = { "bad", "good" };
int rating = Array.IndexOf(codes, "bad") * 5;
Now do the VB one!
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 2 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
modified on Wednesday, April 15, 2009 11:05 AM
|
|
|
|
|
Um, the Array.IndexOf method looks a little off. Shouldn't it be Array.IndexOf(codes, "bad") ?
|
|
|
|
|
Yeah, now fixed, my brain needs rest now!
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 2 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
leppie wrote: Yeah, now fixed, my brain needs rest now!
...too much VB code for that one
|
|
|
|
|
I wouldn't know where to start, except for tossing out all those fancy brackets and semi-colons...
|
|
|
|
|
Leppie, I think you need to step away from the computer and get some rest.
|
|
|
|
|
Doesn't this actually gives a rating of 0 ("bad" is the first element, and 0 * anything = 0)?
Dybs
|
|
|
|
|
Looks like VB is scoring better,...
Dim codes() As String = New String(){"bad", "good"}
Dim rating As Integer = (Array.IndexOf(codes, "bad") + 1) * 5
It feels good to learn and achieve
|
|
|
|
|
Ah the expressive powers of VB and its native speakers
|
|
|
|
|
Oh, come on... Even VB can do this in one line plus exception handling...
Try
Return t.Select("linatipedi='N'").Length = 0
Catch
Return False
End Try
Man, if this is a 5, I'd really hate to see a 10...
Translation: Post one of the 10's! Heheh
|
|
|
|