Error when using conditional breakpoint with instanceof.Is it me or eclipse? - eclipse

My condition for break :
event instanceof org.geomajas.gwt.client.widget.event.SearchEvent
I have tried other variations like event instanceof SearchEvent / with parantheses and with/out ";"
The error : Evaluations must contain either an expression or a block of well-formed statements
The solution: ?
BTW I'm using jdk 1.6.25

return event instanceof org.geomajas.gwt.client.widget.event.SearchEvent;
should do the trick

Related

Conditionally execute a funtion, throws error `Conditions must have a static type of 'bool'. Try changing the condition`

I want to feed Two to the function. When function receives Two as the data, it should print success to the console. But seems like it's not the correct way.
Error: Conditions must have a static type of 'bool'. Try changing the condition.
List
enum ButtonList {One, Two, Three}
Calling function
testFunc(ButtonList.Two)),
Function
testFunc( ButtonList type) {
if (type = ButtonList.Two ){print('sucess ')};
}
It should be:
testFunc(ButtonList type) {
if (type == ButtonList.Two) {
print('sucess ')
};
}
There's a big difference between = (assigning a value to a variable) and == (equality comparison). if expects a condition (==), not the assigning operation (=).
Formatting is important to read and understand the code. Please read Dart best code style practices: https://dart.dev/guides/language/effective-dart/style
You are trying to assign with =, use == instead

Why am I getting this error in python when i enter into next line of if-else condition?

if cake == "delicious":
return "yes"
SyntaxError: 'return' outside function
Why I get like this?
You can create some functions like this.
text ="delicious"
def check(text):
if text=="delicious":
return 'yes'
check(text)
return is a keyword which can only appear in a function definition (as the syntax error says). You can simply print your output in an if/else block
if cake == 'delicious': print('yes')

Why do I have error in the expression editor when I sum BigDecimal in Jaspersoft Studio?

I want to sum two BigDecimal, but before to do that I need to know that this values are not null (I could made this check Java side, but I want to try Jasper side).
So, I do this check:
($F{a} != null ? $F{a} : new BigDecimal(0))
($F{b} != null ? $F{b} : new BigDecimal(0))
Now, I have to sum a and b, but if I do:
($F{a} != null ? $F{a} : new BigDecimal(0)).add($F{b} != null ? $F{b} : new BigDecimal(0))
I get:
The current expression is not valid. Please verify it!
How can I solve?
Assuming that your fields are both of class java.math.BigDecimal and that you are using language="java" or language="groovy"
There is nothing wrong with your expression!
Don't worry about the Expression Editor it simple can not understand that ($F{a} != null ? $F{a} : new BigDecimal(0)) is a java.math.BigDecimal, that is why it states "The current expression is not valid. Please verify it!" and show's a red dot at .add.
Just press "OK" and enjoy your result!
If you like to simplify your expression's or just remove the error in the expression editor, you can use variables.
I had the same problem. Explicitly casting a new BigDecimal eliminates the exception. Use
new Bigdecimal($F{a} != null ? $F{a} : new BigDecimal(0))
and there should be no problem.
I was wrong. The cast eliminated Jaspers' compile time exception but in runtime it threw 'The constructor BigDecimal(NumberComparable) is undefined.' Note the compile time exception is bad since their approach is to check each keystroke and throw up a warning as you type. In order to complete typing the conditional, it takes double the effort in warnings closing. Now I need my code to work without the cast and I'm about to try
($F{denominator} == 0 ? 0 : $F{numerator} / $F{denominator})

How to call functions inside ternary operators in UnityScript?

I'm trying to decide which function to call, based on a boolean value.
myBooleanVariable ? function1() : function2();
Unity gives the error :
Expressions in statements must only be executed for their
side-effects.
So why does this not work, and how can I make it work ?
Thanks for any help !
So why does this not work, and how can I make it work ?
If it's true that it doesn't work (I don't have Unity to hand), it means UnityScript (Unity's implementation of JavaScript) doesn't support the expression statement. Which puts it at variance with the specification, and means a fair number of JavaScript idioms won't work in it. Your line is perfectly valid JavaScript/ECMAScript. You might check to see if there are "lint"-style options you can enable/disable.
The solution would be to use the result of the expression, or rewrite that using if.
Use the result:
var f = myBooleanVariable ? function1() : function2();
Using if:
if (myBooleanVariable) {
function1();
}
else {
function2();
}
Or if you really want the if to be on one line:
if (myBooleanVariable) function1(); else function2();

How do you write an empty while loop in Coffeescript?

I'm trying to translate some old code to Coffeescript. But there is no direct translation for:
while ( doWork() ) {}
"while doWork()" with nothing after it results in a syntax error.
while doWork() then
Should do the trick
using then is probably the canonical solution since it is explicitly meant for separating the condition from the (in this case empty) body. Alternatively you can write
while doWork()
;#
(the # keeps vim syntax highlighting from flagging it as an error)
I also like the continue while doWork() solution, but I strongly advise against any other form of expression while doWork() mentioned in the comments since when this is the last statement of a function it will become a list constructor:
_results = [];
while (doWork()) {
_results.push(expression);
}
return _results;