|
Is it anything like this extension method[^]?
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Only in how it works; not in what it does.
I don't think that will work with TreeNodes because TreeNodes are not themselves IEnumerable and the Nodes property is a non-generic IEnumerable.
I can't even add that finally because IEnumerator (the non-generic one) is not IDisposable.
The Nodes Property also has the benefit of never being null, and the TreeNodeCollection has a Count Property.
What I'm doing also needs to know the stack depth for each Node.
There are other things that are unique to what I'm doing that a general method like that is unlikely to support.
And mine uses only one while loop and one Peek. Why are they so wasteful?
And, yes, I made an Extension Method for TreeNodes -- it's an alternative to ToString() .
Thanks for showing me that.
Interesting to see that I'm not the only one to think of this technique.
Hey, that one doesn't yield the root object? I think it needs work.
|
|
|
|
|
A quick manual trace and it adds the root IEnumerator and then enumerates it, yielding the objects. Then is goes on to get more enumerators.
It is used here[^] to flatten a directory tree to a list of files and folders.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Yes, the enumerator of the root, but not the root itself.
|
|
|
|
|
PIEBALDconsult wrote: System.Windows.Forms.TreeNode nod = this.tvMain.SelectedNode as System.Windows.Forms.TreeNode ; Why do you complain? That cast is really safe, isn't it?
And I am nod ding my head for his great capabilities in naming of variables.
|
|
|
|
|
Yes, that cast is very safe. However, originally I was casting to a custom derived TreeNode type, I could probably remove it now.
|
|
|
|
|
var fieldName = attributeVal.substring(0, attributeVal.length - 1);
It is javascript.
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /
|
|
|
|
|
Why making things simple when you can over-complicate them?
You always obtain more by being rather polite and armed than polite only.
|
|
|
|
|
phil.o wrote: Why making things simple when you can over-complicate them? Because we are men, not women.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Casual sexism alert.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Well that will work, but it is another example of why I have the sig that I do.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
Nice find. But what will happen when attributeVal is null?
|
|
|
|
|
Then run time error would occur.
Actually null value is not a problem. The problem is, the style of assigning a string variable value to another variable.
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /
|
|
|
|
|
Maybe the author wants the original string left unchanged? It is no longer an attribute value but now a fieldname so it makes sense to use a different variable? Have to admit, I don't really get this one
|
|
|
|
|
Good catch. But there is nothing in code to keep string left unchanged. It was simple assignment. I think, first author had extract multiple values from the string but after some changes, the string was started giving single value. The second author may be don't want to change too much in code (specially substring function).
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /
|
|
|
|
|
It's Javascript. You probably end up with fieldName == "undefine"...
|
|
|
|
|
How does it differ from JQuery?
I do not fear of failure. I fear of giving up out of frustration.
|
|
|
|
|
That allows for an easy performance improvement with V2.0
|
|
|
|
|
A real example of Weird and The Wonderful.
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /
|
|
|
|
|
What if he didn't want the original string reference ? not a bad way to clone
TVMU^P[[IGIOQHG^JSH A#@ RFJ\c^JPL>;"[, /|+&WLEZGc
AFXc!L<br />
%^]*IRXD#@GKCQ R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_ADEPABIKRDFVS)EVLQK)JKQUFK[M UKs$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
That only applies to objects. For instance...
var a = 'howdy';
var b = a;
a = 'partner';
alert(b);
var x = {message: 'howdy'};
var y = x;
x.message = 'partner';
alert(y.message);
And even if that was the coder's intent, it would still be way more readable to do something like this...
var a = 'blah';
var b = new String(a);
a = 'yo';
alert(b);
Jeremy Falcon
|
|
|
|
|
Well, substring omits the character at the index specified by the second parameter, so the code you listed will return attributeVal with its final character removed.
Maybe that's not what this code should be doing in this case, but what you showed isn't obviously incorrect. It's exactly the code you'd want to use to remove the last character of a string, although
attributeVal.slice(0,-1) would work in this case too.
OTOH,
var fieldName = attributeVal.substring(0, attributeVal.length);
would be pointless, as it would just return attributeVal
|
|
|
|
|
Sanjay K. Gupta wrote: It is javascript. You don't say!
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
That made my day.
Jeremy Falcon
|
|
|
|
|
There are increasing numbers of questions being posted with code similar to:
try {
callAPIMethodThatReturnsStatus(some parameters)
}
catch (SomeException e) {
take exceptional action
}
display ('The method completed successfully');
And yet they never check the returned status of the method call. Someone is teaching students/newbies that if it does not throw an exception then it must have worked. This seems most common with database update commands.
Get your money out of the bank quickly.
|
|
|
|