sai rama krishna wrote:I do not need this else block as per challenge requirement. Can you please point me why i got error in first case but no erro in second case?
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Because of the rules of Java. Your code has to return something in every branch of the if-else statements; your first version doesn't do that
No, ∧ is logical AND.Tim Holloway wrote:. . . you're using an exclusive-OR operator (inverted V) where you should be using an inclusive-OR (non-inverted V). . . .
You had nothing saying to return false. The second if didn't have a corresponding else. If both the ifs had turned out to be false, there is a path of execution which returns nothing. An else is unnecessary if you write return false; after all the ifs.sai rama krishna wrote:. . . I did have return statement in if block and else if block . . .
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
No, because line 19 will be executed if any path through the if‑elses fails to return a result.sai rama krishna wrote:. . . Below I did not get such error. . . .
If you are getting into the realms of an absurd value, should you consider throwing an exception instead?Tim Holloway wrote:. . . default absurd value . . .
sai rama krishna wrote:Is it because of compound logical statements we discussed earlier in one of the post? I am not clear on what special character issue here relating to XOR
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
What is a compound logical statement? I don't think that is a standard programming or logic term.sai rama krishna wrote:Is it because of compound logical statements we discussed earlier in one of the post?
There is no XOR in what I wrote.I am not clear on what special character issue here relating to XOR
Campbell Ritchie wrote:
If you are getting into the realms of an absurd value, should you consider throwing an exception instead?Tim Holloway wrote:. . . default absurd value . . .
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
∧ No, that is an AND operator.A few hours ago, I wrote:. . .. . . .
Campbell Ritchie wrote:
Symbols:- ...
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
What if neither of the if conditions are true? Then the marked return statements controlled by the if statements would not be executed. The compiler requires a return statement for all cases.
sai rama krishna wrote:
So while writing code as a coder i am responsible to imagine run time behaviour also right?
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
sai rama krishna wrote:Is it good idea to declare
boolean ret=false in line 2 and assign in if loop and else if loop and return ret as below? I can follow if this is good approach moving forward for these type of challenges
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I am used to ⊃ meaning (strict) superset. I have ~ on the right, as shift‑#. As I said, every book seems to have different symbols in.Tim Holloway wrote:. . . a sideways U with the bow on the right . . . I don't think their standard character set had tilde. . . .
With the exception that NOT usually has the higest precedence, Java®'s precedences and C's, which Java® follows, differ greatly from classical logic notation.. . . Operator precedence can vary somewhat depending on the language being used . . .
Good to see you again, FredFred Rosenberger wrote:your line "ret=true" is not needed. as soon as it hits the line above with "return true;", you leave the method. I'd expect you might get an "unreachable code" error if you compiled that.
And did you notice the two are almost the same puzzle, differing mostly in the numbers?sai rama krishna wrote:I just did same thing for other challenge . . .
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
There are three kinds of actuaries: those who can count, and those who can't.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:I just spent the morning unravelling a mess of them because I had to do some tracing with a debugger and they weren't fine-grained enough:
I needed to be able to inspect the object getMap() was returning.
There are three kinds of actuaries: those who can count, and those who can't.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
RTFJD (the JavaDocs are your friends!) If you haven't read them in a long time, then RRTFJD (they might have changed!)
That involves the implication operator ⇒, and we already know there isn't such an operator in Java®. I showed here how you can implement something logically equivalent to ⇒; please have a look at the two options. Plugging those versions of implication into the formula above, we get two options:-The version 2 code may become easier to read if we eliminate the negation by swapping the 2nd and 3rd operands:-Use the contrapositive rule...and we can translate that into Java® as:-[edit[Spellling correction to some of the HTML tags.Yesterday, I wrote:. . .. . .
Maybe there is something wrong with that code. I started by thinking it is an inappropriate use of ?:, but now I think the problem is something you can read about in Joshua Bloch's Effective Java: inappropriately returning null. Maybe the getMap() call shouldn't return null in the first place. Maybe if the map is null, the code should take one of the options from Bloch, or throw an exception. Maybe it should incorporate a containsKey("foo") call, too. Obviously I don't know enough about the code to make any firmer recommendations.Piet Souris wrote:
Well, that code, although nothing wrong with it . . .Tim Holloway wrote:. . .. . .
There are three kinds of actuaries: those who can count, and those who can't.
Does that stand for Joint Logical System?Piet Souris wrote:. . . JLS! . . .