« first day (695 days earlier)      last day (3324 days later) » 

12:00 AM
where it looks for "substring" within "string" but only in the given range
 
There are 1260 unanswered questions
 
Where range is a struct with a starting index and a length.
 
Oh.
I have a similar one:
string value, int startIndex, int count
 
count is a length?
 
Yes.
 
12:01 AM
What does the method call look like, so I can write you an answer...
ParentString.IndexOf(SubString, 0, ParentString.length)
Like that?
 
Yes.
 
Now, respond to my comment.
 
Boy, if I had thought to check that before...
@nhgrif Done.
 
what does indexof return if none found? -1?
 
Yes.
Want me to load my test project up on Github?
If Ideone supports multiple classes, I'll put it there.
There you go.
 
12:08 AM
while ((startingIndex = str.IndexOf(val, startingIndex, (str.length - startingIndex))) >= 0 && (startingIndex < str.length) {
    ++instancesOf;
    ++startingIndex;
}
Is that valid C#?
 
Almost.
You are missing a brace.
 
Oh yeah, at the very end
 
I mean a parenthesis.
At the end of the while
Also, you don't need to put braces around everything.
(str.length - startingIndex) doesn't need braces because it is separated by commas.
 
You can put parens however you want.
 
Yes.
 
12:10 AM
I overdo mine sometimes.
 
This doesn't need it either: (startingIndex < str.length)
 
Does that assignment in the conditional of while work?
What happens if startingIndex > str.length in indexOf?
 
Yes, at least it does in my question.
Not sure, but it crashes if count extends beyond the length.
It crashes with an IndexOutOfRange exception.
@mjolka I do need the copy variable.
Otherwise, it changes my original string, and I can't have that.
Oh, not with your implementation, it doesn't.
 
You don't need to copy the variable with my implementation.
 
@Hosch250 strings are immutable
 
12:15 AM
Nope, not with either of yours'.
@mjolka Yes, but in my implementation, I was changing the actual value of the copied string.
 
@mjolka that's why we use stringBuilder when needed :)
 
@Hosch250 no, you're not
 
@mjolka Yes I am: copy = copy.Remove(indexOfVal, val.Count());
 
0
Q: function to delete node with given value from BST

code_help_neededI have a struct called TreeNode with an int key, and left right and parent. I am trying to delete a node from a tree with my DeleteNode function and it is not working. I am supposed to replace the deleted node in my DeleteNode function with the max value from the left subtree. My transplant and m...

 
@Hosch250 what do you expect this to print
var x = "abc";
x.Remove(0, 2);
Console.WriteLine(x);
 
12:17 AM
You're not changing the variable outside the method though, @Hosch250
 
@mjolka "abc", of course.
 
The only reason you're changing copy is because you're assigning the result to it.
 
right
@Hosch250 and what about this
void Main()
{
    var x = "abc";
    Console.WriteLine(x.Foo());
    Console.WriteLine(x);

}

static class StringExtensions
{
    public static int Foo(this string foo)
    {
        foo = "foo";
        return 42;
    }
}
 
Would it be "foo", or would it be the same as originally?
 
it prints 42 then abc
 
12:20 AM
So... this public static int Foo(this string foo) just means you can call x.Foo() or String.Foo(x), right?
 
@nhgrif it means you can call x.Foo() or StringExtensions.Foo(x)
 
" I'll post my current code as a possible answer. " Please provide your code in question. And if code works, maybe code review is better than SO. — Marcin 1 min ago
 
So, @mjolka didn't use the assignment in the loop, and @nhgrif did.
 
0
Q: Infix Conversion

manutdI'm writing code to convert Infix expression into Prefix.I have a problem with my code , if i input this expression x*y+((z*k)-(n/m)) I'm getting answer like this : mn/kz**y*x+ The correct answer is : mn/kz*-y*x+ I know there is a problem with my code but i'm not able to fix the issue . #i...

 
The best is probably somewhere in between our answers. I really don't like start != -1
 
12:26 AM
I went with yours for now.
But, it is alright to do the assignment in the loop?
 
@Hosch250 do you see that copy is unnecessary now?
 
@mjolka Yep.
 
cool
 
I tested my version with it out, just for the heck of it.
It worked the same.
 
always good to test :)
 
12:27 AM
@Hosch250 I don't know. It's perfectly expected in C and not that strange in Objective-C. I don't know if it works in C# or not. That's why I asked.
 
@nhgrif Yeah, it works.
Just not sure if it is good practice.
@Mat'sMug Is assignment in a while loop good practice in C#?
 
It eliminates some code duplication. You see mjolka's answer has to have IndexOf on two seperate lines.
 
Yes, I like the assignment better myself.
@nhgrif I think this: ` >= 0 ` should be != -1, shouldn't it?
Posted a comment on your answer, @nhgrif
 
Anyone here familiar with JavaFX?
 
12:44 AM
@Hosch250 If you want to rely on that always returning -1 when it's not found.
 
@Hosch250 depends on the contex...
 
I guess I'll do it your way in case it changes, but I can't see it changing.
3
Q: Counting occurrences of substring in string

Hosch250I need to know how many times a substring occurs in a given string. I figured that I might as well create an extension method: public static int Occurences(this string str, string val) { string copy = str; int instancesOf = 0; int indexOfVal; while ((indexOfVal = copy.IndexOf(...

There's the context, @Mat'sMug
 
ah
 
Also, @Hosch250, try my method with "abcdefgabcdefgabcdefg".Occurrences("g")
It'll probably crash.
 
I don't see a problem with assigning in a loop. ...people do that all the time...
 
12:46 AM
OK.
 
oh wait
 
@nhgrif Nope.
 
My guess is that my implementation crashes if the passed in value is a single character string and it's found at the last valid index.
 
0
Q: Debug logger for Free Pascal / Lazarus

cpicancoDebug experience can be much improved in the Lazarus development interface. Please, if you use this free development environment and have the same felling, do not consider this affirmation simply as a "drawback". I would rather consider it as a challenge for improved documentation and contributin...

 
while ((startingIndex = str.IndexOf(val, startingIndex)) >= 0)
{
    ++occurrences;
    ++startingIndex;
}
@Mat'sMug ^^
assignment in the conditional.
 
12:47 AM
No, because it tries to get the next value, crashes with an IndexOutOfRange exception, fails to assign, and sets the condition to false because of the failure.
 
The exception doesn't propagate all the way up?
 
@nhgrif that's more annoying ;)
 
No, it gets caught in the loop.
 
It's extraordinarily common in C. I've seen in plenty (and used it myself) in Objective-C.
I wasn't sure whether it'd work in C# or not. But in this case, it eliminates duplication of IndexOf as seen in mjolka's answer.
 
it would. I just don't like reading a code line, and then thinking "wait, what?" and then reading the line again just to be sure of what I saw
 
12:50 AM
I could make it even worse...
 
lol I know you could ;)
 
for (int startingIndex = 0; startingIndex >= 0; ++occurrences, startingIndex = 1 + str.IndexOf(val, startingIndex));
body-less for.
 
a for-loop that starts with a wink-wink is never a good sign!
 
Oh wait
 
Boy, I like that body-less for!
 
12:52 AM
It doesn't have to start with a wink.
 
JK, anyway, supper is on.
BBL.
 
later!
 
better?
 
I don't think it's good for readability to include part of each iteration's logic outside the body of a loop.
 
Every for loop does that.
 
12:57 AM
it does look better though
uh, well, yeah...
 
for (initialization; conditional; update) { body }
Our update is simply more complex than ++i, which, by the way, is just as normal for a for loop than the assignment within the conditional of a while loop.
Moreover, importantly, we don't actually care what startingIndex is at ANY point outside of the conditional.
So actually, logically, it definitely belongs inside this part, whether it's a for or while loop.
 
you're right
lol and I suck at writing clever code :/
 
And while we could put ++occurrences in the update part, logically, it definitely belongs in the body.
 
it does
 
@nhgrif the code in that screenshot is very broken. take "x".Occurrences("y"). it will increment occurrences, then set startingIndex to 1 + -1 = 0, then increment occurrences, then... it's an infinite loop
 
1:02 AM
Oh yup.
 
^^ why I don't write clever code
 
So...
public static int Occurences(this string str, string val)
{
    int occurrences = 0;

    for (int startingIndex = str.IndexOf(val, startingIndex);
         startingIndex >= 0;
         startingIndex = 1 + str.IndexOf(val, startingIndex))
    {
        ++occurrences;
    }

    return occurrences;
}
And that still doesn't work.
 
I'd probably have the update logic extracted into a function, so that it's clear that the loop is only iterating actual occurrences
 
The for loop I'm still not sure about. The while loop works though.
I removed the for loop from my answer.
 
good call. i think our answers are similar enough now that i'll remove mine, it's not really adding anything
 
1:06 AM
Is there a way to combine our answers into community wiki?
Would that be appropriate here?
We posted within 3 minutes of each other.
 
there should be a checkbox in the edit page
 
i don't have any experience with CW, but if you know how, feel free :)
 
How about you two remove your answer and I'll post the updated one
Fair for everyone
 
@mjolka you make some comments about the copy variable, about Length versus Count(), and offer solutions for both overlapping and non-overlapping.
 
Length over Count() is definitely a good point to mention
 
1:08 AM
I will turn mine into community wiki and you add those points to the answer?
 
The .Count() is actually really important
That should be a note for sure
That's an O(n) lookup each iteration
 
Wait, how do I make community wiki...
 
edit -> select CW bottom right
 
@nhgrif Hosch was wrong about the exception being swallowed -- no exception is thrown when you call x.IndexOf("foo", x.Length)
 
"fooooo".Occurrences("o")
 
1:10 AM
it didn't make sense that an exception would be automagically swallowed there
 
What's that do?
It should either return 5 or throw an exception.
 
var expected = 5;
 
returns 5
 
My answer is community wiki so clean it up, add @mjolka's points.
And perhaps we need to figure out why mine doesn't throw an exception or just remove my comments about the exception.
 
what should throw an exception?
 
1:13 AM
str.IndexOf(val, startingIndex) with startingIndex >= str.length
Which, as far as I can tell should happen if val has a length of 1 and is found at the last valid index.
 
it's by design https://msdn.microsoft.com/en-us/library/7cct0x33(v=vs.110).aspx "`ArgumentOutOfRangeException`:
startIndex is less than 0 (zero) or *greater than* the length of this string."
formatting is hard
 
Ah.
> If startIndex equals the length of the string instance, the method returns -1.
@mjolka Are you editing your unique stuff into the now CW-answer?
And if not, can I copy stuff out of your answer into CW answer?
 
@nhgrif i was about to, but if you're offering :) i'll go for a smoke instead
 
-1
Q: Why do I only get 0's when I am doing math operators? Here is my program. Any help is appreciated.

Kent N.public static void main(String[] args) { System.out.print("I am a math machine! I will do calculations for you."); //declare vars Scanner in = new Scanner(System.in); int num1 = 0; int num2 = 0; int addition = 0; int subtraction = 0; int sum = 0; int differenc...

 
@CaptainObvious apparently the "Ask a Question" sidebar isn't obvious enough
 
1:22 AM
There. Someone who knows C# better than I could elaborate on Length versus Count().
 
Length is a property, Count() is a method; the getter simply retrieves a field value, the method actually counts items
 
> The program does run. I just do not receive the correct answers. All answers come out as 0's.
Should we even bother making this close reason more accurate?
 
@Jamal No.
That's what you get if you click the "Broken Code" link
 
@Jamal the sidebar would be a flashing marquee, we'd still get broken code questions...
 
1:28 AM
True
 
So wait...
-1
A: Driver license program which grades an individual's responses

MisunderstoodThe first thing I would do is convert A,B,C, and D to 1,2,3, and 4. Maybe 0-3, not sure yet. yeah 0,1,2,3. 0,1,2,3 just makes so much more sense than A,B,C,D. Very likely down the road it will prove to be a good move. Do an ASCII to numeric conversion and subtract x41 or 65 if you are a normal ...

I can vote and comment on this answer now
but it's still locked
Oh no
It's not locked, it just still has the notice on it.
Might want to remove the notice?
 
Actually, it turns out it's not. I cleared the offensive flag, which apparently unlocked it without removing the post notice.
So yeah, I'll remove it now.
If it gets rolled back again, do flag it.
 
No problem.
There's no reason to smoosh a for loop down to a single line. Fewer lines doesn't mean better code. White space can be very valuable from a readability perspective. — nhgrif 3 mins ago
Additionally, this answer does not account for lowercase letters. The originally code treated lower and uppercase letters equally. Both were accepted as inputs, and both A and a would be considered correct if the correct answer is A, while your solution would only accept capital letters. And given that we're expecting input in the form of characters, I actually think your answer has unnecessarily complicated the matter far moreso than the original code in the question. — nhgrif 1 min ago
 
hi
 
And, for what it's worth... subtracting decimal 65 or hex 0x41 both make no sense. I'd subtract the character 'A' if I were doing it his way.
 
1:37 AM
hi!
 
1
Q: Debug logger for Free Pascal / Lazarus

cpicancoDebug experience can be much improved in the Lazarus development interface. Please, if you use this free development environment and have the same felling, do not consider this affirmation simply as a "drawback". I would rather consider it as a challenge for improved documentation and contributin...

Please, see the comments
And make me know if I am doing something wrong. :)
 
@200_success the Z algorithm link is broken
If your val is long, and your str is pathological, the running time could be O(n^2). To avoid that, you could use a smarter string-searching algorithm, such as the Z Algorithm, which works in O(n) time. — 200_success ♦ 32 mins ago
 
@cpicanco you're not - it's just that all SE content is CC-by-SA; by posting it there, you're posting CC-by-SA, not GPL3
I'd just remove the license part to avoid confusion
 
Whats the question ? How to get input, how to do the collision detection, code review ? You have to be more specific. — LJ_1102 1 min ago
 
I am afraid that I can't remove it. GPL3 requires to refers to the licence.
 
1:43 AM
then I'd have to include that license gibberish on every single one of my Rubberduck-related CR posts.
you're not sharing the source code, you're sharing bits & pieces of something you completely own, that you licensed as a whole under GPL3
I might be wrong, but that's how I see it
anyway whatever is posted here isn't GPL3, it's CC-by-SA
 
but GPL3 applies, as a whole, to any part of its content.
 
Which means either remove the licensing part from the question, or remove the question as a whole...
 
so what? you're going to sue yourself for posting it under CC-by-SA?
 
Because GPL3 doesn't apply to code you post to Stack Exchange. CC-by-SA does.
I don't know if those two are compatible.
 
well they better be, otherwise I have tons of shit to edit
 
1:46 AM
But if it's on Stack Exchange, it's CC-by-SA. Having GPL3 up there makes it confusing because the GPL3 isn't applicable in the slightest to the stuff you've posted to Stack Exchange.
 
I think that the discussion around the code is CC-BY-SA 3.0 and the code, just refereed in the question, is GPL3. No conflicts at all afaik
 
Then remove the GPL3 stuff from the question?
 
but including the license part along with the post makes it seem like you're posting under GPL3, and you're not.
 
You've linked to the source code, right? And the source code, which is not on Stack Exchange, is under GPL3, right? And where the full source is actually located, it has the GPL3 licensing all over it, right?
 
I just intended to avoid repetition. I could post the original code.
 
1:48 AM
^^
@cpicanco that's not the point
the point is that whatever you post on SE is automatically CC-by-SA
 
You should post whatever you want reviewed on Code Review.
And whatever you post is CC-by-SA, not GPL3.
 
Comments are important part the code... hum?/?
 
And putting GPL3 licensing in the question makes it extraordinarily confusing.
 
^^
 
Comments are an important part of the code. Do you want answers about your copy&pasted license agreement comments?
 
1:49 AM
I understand, but the confusion is in the world, not in the question...
 
The question is confusing.
Do you want the licensing reviewed?
 
no, you are confused here - how much sense does it make to include GPL3 legalese on stuff that's actually CC-by-SA?
 
Let me think about it!!
 
this code is GPL3:
8
Q: Rubberduck's "Rename" refactoring implementation

Mat's MugKnowing who's using what, and where, I've implemented a "Rename" refactoring for Rubberduck. It works great - it needs further extensive testing, but the preliminary tests are very, very exciting. There are a few things I'm not sure I like though: The entire logic is implemented in the Rubb...

 
I've just voted to close your question as unclear. Ping me when the licensing is removed.
I'm going to bed.
 
1:51 AM
this code is GPL3:
15
Q: Who's using what where - turning code into symbols

Mat's MugThe Rubberduck project is coming along pretty nicely, and for the next version the parsing strategy is getting yet another revision, and this time around it really feels like it's done right. Or is it? The idea is to walk the parse tree once to locate every single declaration. Here are the typ...

this code is GPL3:
15
Q: Rubberduck's "Extract Method" refactoring implementation

Mat's MugWith the ANTLR-powered parser, I was able to reimplement all code inspections from the last release build, and the rest of the inspections on the road map are now implementable. Code inspections and quick-fixes are nice, but we want our Rubberduck even smarter than that. So I wrote one of the ...

'night @nhgrif
and I could go on and on
the code in the repository is GPL3
the code on CR is CC-by-SA
both licenses are compatible, so no worries
 
I've voted to close this question as unclear what your asking. Code posted to Stack Exchange is under CC-by-SA 3.0 license. The GPL3 licensing comments is very confusing. Do you want your licensing comments reviewed? Are you trying to apply a license to the code in the question which you can't possibly do? — nhgrif 36 secs ago
 
unless I missed something. but then I own the code base
 
Thank you guys, I will think and study the licences before any further action.
 
@nhgrif I wouldn't close for that reason.
no problem
but nhgrif is right, it does look like you're trying to apply GPL3 on Stack Exchange content, which you cannot do
 
Thank you nhgrif for your wise action.
I don't.
I am trying to avoid conflicts.
 
1:55 AM
then the simplest thing to do is to avoid including any form of licensing information in the post
 
I am afraid that I can't do this. But I am not sure, so, lets study the licenses.
 
whatever you post is CC-by-SA. if you have code under a license that doesn't let you share some of it under CC-by-SA, then don't post it on SE...
> The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. **By contrast,
the GNU General Public License is intended to guarantee your freedom to
share** and change all versions of a program--to make sure it remains free
software for all its users.
@cpicanco CC-by-SA requires attribution - that's what makes it compatible.
 
@mjolka Fixed. Thanks.
 
> You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
 
The copyright holder isn't beholden to the terms of the GPL.
 
2:05 AM
@cpicanco you own that code, do you?
 
And is free to relicense the work in any way he/she wants.
 
@200_success that was my understanding
 
Assuming that a sane person wouldn't sue himself
 
21 mins ago, by Mat's Mug
so what? you're going to sue yourself for posting it under CC-by-SA?
lol
 
Yes
I own that code.
 
2:09 AM
I'm curious what makes you reluctant to remove the GPL part then
 
Curiosity.
I want to know more about them. Be patient guys! I am reading the licenses here.
I am not as fast as you with the English... :P
 
@cpicanco you fear that posting parts of it under CC-by-SA makes you lose rights on that code? By posting it to CR, the version you published under CC-by-SA can be used by anyone that browses to it, provided that they say where they took it. And the version you modify after receiving your review, if it remains in your repository, remains under GPL3.
that's how I see it anyway
 
2:41 AM
0
Q: Need help in reviewing my JS code

MaverickI have been learning HTML/JavaScript and CSS. I have gone through some of the online tutorials, PDFs and books as well. Though, now I am familiar with syntactical stuff, I wasn't sure how I should design or structure code, so I started with a small ToDo application. I didn't want to use any frame...

 
> Last 2 weeks:

365 incoming zombies (new questions asked) | 26.1 per day
531 answers given | 37.9 per day
1,187+365−531=312 zombies down | 22.3 per day (+3.8 zombies daily)
2,054 answer votes spent | 146.7 per day (~3.7 users running dry on ammo)
I would love to see more detailed stats, as they were in the other post: Incoming Zombies, No. of posted answers, No. of shot zombies. I don't think we're answering less than on the first mission, but I percieve there's more answers to a question now, and there's definitely significantly more incoming zombies — Vogel612 8 hours ago
 
0
Q: Open a Com port and Send an ASCII String.

Patrick EvansThis is my first ever project and first Gui. I have finished it (With help from stackoverflow)and it works but is very slow. Can anyone suggest improvements for speed, Best practices or usability. It currently takes 16 seconds from pressing run in Eclipse to something appearing on my screen. ...

 
2:58 AM
In accord with my reading, it turns out that the CC-BY-SA 3.0 is not GPL compatible. It is the recommended one for comments, discussions, and so on, though. To the author standpoint, seems that you can bring code from GPL to CC-BY-SA to discussion, by revoking the copyleft, and brings back to GPL by revoking your own rights, not the others, of course. Works for me. :)
 
also, this is a better q for [codereview.stackexchange.com/](Code Review], unless you can pinpoint specific problems with this, general questions about "how to make this run faster" or otherwise optimizing your code should probably go there instead. — David Zemens 1 min ago
 
I just got rid of the separate file for search results and merged them into my data tree of items.
Everything is getting so much cleaner now...
@nhgrif When I did these changes, I managed to get Occurrences to crash.
I solved the problem by putting the startingVal < str.Length back in.
 
3:31 AM
0
Q: VBA find function too slow, faster method possible?

SamatarIn column A, I have many strings ~ 32000 cells each containing unique string values. I then have columns C to as many as 30/40 columns which all contain approximately 400 rows of text. •Check column (j) for any text not present in column A •If true then add new string to column A •Run comparison...

0
Q: Game of life in JavaScript - using Table

Sandeep kumar H RI finished coding Conway's Game of Life in JavaScript and HTML table. logic cells in a table will be assigned with unique id's and based on the id operations(based 4 rules) take place. You can find the working code at Codepen or i have put the code below. The thing is it works well with any numbe...

 
3:52 AM
I agree with @DrewDormann. I think it would be best to define "elegant", if you want to make it a beauty pageant it's not a good place. If by elegant you mean best in terms of time/space complexity it would be better. I also would understand the urge to write it in proper modern c++ idioms. It's hard if you are not familiar with it. Perhaps best way it to write something that works, and put it on codereview. At least it would show some effort rather than being possible to interpret as "Write me some code, i'll take the prettiest one." — luk32 1 min ago
 
4:27 AM
Bed time....
 
'night @rolfl!
 
@Mat'sMug - check out: git.tuis.net/ubench/Linear.html
 
nice chart... what is it?
I need to look at that repo ;)
hey @Unihedro!
 
It's a graph of the scalability characteristics of a simple linear function
 
Heya @Mat!
 
4:33 AM
Unselect plots in the left margin
Or, rather, look at the data table.
 
pretty cool.. but what's the data?
 
private static final long linear(long input) {
    long count = 0;
    while (input > 10) {
        input -= 10;
        count++;
    }
    return count;
}
That's a function that will have linear complexity
The greater the input, the longer it takes.
This is tested with:
    UScale.function(
            data -> linear(data),
            scale -> scale, true)
       .reportHTML("Linear", Paths.get("output/Linear.html"));
The UScale code takes various 'scales' that wok in reasonable time, and tests the function with each scale.
 
ah! enter microbench?
 
Yeah, Simon has been hacking in it for a while too.
He's done the hard things, like matching the actual results to well-known algorithmic complexities
All I did is run the code, and draw pictures
Running the code is OK, but the pictures are in HTML, JavaScript, CSS, and D3
have a look at the source-code for that page
I see a review coming on
 
I see readable JavaScript!!
2
is // not comments?
  //.append("text")
  //.attr("transform", "rotate(-90)")
  //.attr("y", 6)
  //.attr("dy", "-1em")
  //.style("text-anchor", "end")
  //.text("Per second Run Count(limited)");
 
4:40 AM
Yeah, I struggled to get the axis labels to align
Just commented them out
There has to be a better way
 
not quite the comfort zone eh?
 
No, not at all ... ;-) Which, I guess, is half of the idea.
d3 can do remarkable things... it's the guts...
 
5:12 AM
I think this question will be more appropriate in codereview.stackexchange.com. — Karthikeyan Vaithilingam 27 secs ago
I'm voting to close this question as off-topic because it's about improving/reviewing working code. It would be on topic at codereview. — Roombatron5000 43 secs ago
 
anyone here?
 
shhhh..... sleeping
 
@Mat'sMug ahoy
 
does this make sense?
        private static readonly Type[] AssignmentContextTypes =
        {
            typeof (VBAParser.SetStmtContext),
            typeof (VBAParser.LetStmtContext),
            typeof (VBAParser.ForNextStmtContext)
            // todo: verify that we're not missing anything here (likely)
        };

        private bool IsAssignmentContext(RuleContext context)
        {
            return AssignmentContextTypes.Contains(context.GetType())
                || (context.Parent != null && IsAssignmentContext(context.Parent));
 
looks sensible
 
5:24 AM
as in frail?
 
Any reflection is frail
but, if you have to do it .... you have to walk the inheritence tree
 
/s/reflection/recursion
/s/inheritence/parse
 
sure
 
ok
running some more tests...
 
I have just been sucked in to facebook....
 
5:27 AM
I have a bug where assigned variables get flagged as unassigned
like, inspection false positives
I believe it boils down to this method
 
got a friend request from the sister of the guy who used to be my neighbourhood best friend... in 1982...
 
lol
she cute?
 
in the streets of durban... SOuth Africa...
she now lives in toronto... go figure.
 
wow
 
@Mat'sMug looks like the method can be static. and i'd remove the recursion
private static bool IsAssignmentContext(RuleContext context)
{
    while (context != null)
    {
        if (AssignmentContextTypes.Contains(context.GetType()))
        {
            return true;
        }

        context = context.Parent;
    }

    return false;
}
 
5:28 AM
Yeah... I was not friends with her brother on FB....
not sure what inspired her to find me...
have not spken to either of them in .... 32 years
 
@mjolka I like that
 
hell, I was 10 when I left that city
 
@rolfl that's ..my age.
 
@Mat'sMug or you could introduce a helper method
private static IEnumerable<RuleContext> GetAncestorsAndSelf(RuleContext context)
{
    while (context != null)
    {
        yield return context;
        context = context.Parent;
    }
}
 
@Mat'sMug To her husband, surely ;-)
 
5:30 AM
recursion is failing
 
^^^ wrong.
 
Rubberduck Code Inspections - 30/03/2015 1:30:07 AM
75 issues found.
Suggestion: Instruction contains multiple declarations - VBAProject.ThisWorkbook, line 5
Suggestion: Instruction contains multiple declarations - VBAProject.ThisWorkbook, line 4
Suggestion: Instruction contains multiple declarations - VBAProject.ThisWorkbook, line 3
Error: Variable 'EmptyCol' is never assigned - VBAProject.ThisWorkbook, line 5
Error: Variable 'emptyrange' is never assigned - VBAProject.ThisWorkbook, line 5
Error: Variable 'trimrng1' is never assigned - VBAProject.ThisWorkbook, line 5
 
recursion is failing .... is failing ... is failing.
 
using this code:
3
Q: Find function for strings in cells

SamatarIn column A, I have many strings ~ 32000 cells each containing unique string values. I then have columns C to as many as 30/40 columns which all contain approximately 400 rows of text. Check column (j) for any text not present in column A If true then add new string to column A Run comparison ...

 
private static bool IsAssignmentContext(RuleContext context)
{
    return GetAncestorsAndSelf(context)
        .Any(c => AssignmentContextTypes.Contains(c.GetType()));
}
 
5:31 AM
hmmm... nodding off, not agreeing.... TTCME....
 
TTCME?
 
@Mat'sMug Time To Climb Mount Everest
 
well duh!
building
ugh
FML
 
Close my eyes..... and gone.
 
'night!
ugh. I just don't get it. that should work.
 
5:40 AM
0
Q: In file check new line is empty or not?

Mahesh WaniIn a text file check if new line is empty/there is no any text then con-cat all previous string in one line?

 
@CaptainObvious kill. with fire.
I'm stuck with these false positives, dammit.
1:45AM, another day without a solution.
 
6:27 AM
And inspecting that nasty VBA code revealed some unsuspected regression bugs with my code. Not going to sleep well...
 

« first day (695 days earlier)      last day (3324 days later) »