Just discovered the Code Fragment Evaluation function...
.... and I have to say I was rather pleased and then a little saddened when I
became unsure of exactly what I can do with it?
Is it just a means of trying out different expressions in the same window,
as it only seems to run the last expression I enter - much like the standard
Expression Evaluation? If it does only run the last expression in the text
area, what is it's purpose? I suppose it might be a means of seeing multiple
tried expressions in the same window, but that seems a bit pointless too?
- scott
Please sign in to leave a comment.
Scott Curtis wrote:
You can run arbitrary code fragments in there. Like this for example:
String a = "a b c";
StringTokenizer st = new StringTokenizer(a);
while (st.hasMoreElements()) {
String s = (String)st.nextElement();
System.out.println("s = " + s);
}
In fact it does run the whole code, but just displays the result of the last
expression that has been evaluated. However, the formatting is quite awkward
as it puts the whole code into one line together with some value. Instead it
should actually display just the last evaluated expression only to make clear
where the value comes from.
There's also a problem that doesn't allow the instantiation of primitive type
arrays, see http://www.intellij.net/tracker/idea/viewSCR?publicId=35435 which
I still hope that it gets fixed for 4.5.
Sascha
It is actually very useful.
It gives you the last expression output, but you can create variables, use
iterators, etc. before that.
Think of this mode as writing an ad hoc debugging method.
Just like a method, you can write any code and instantiate any variables,
while your inputs are your current breakpoint frame state variables, and the
return value is the last expression.
Hope this helps,
Amnon
"Scott Curtis" <scurtis@smart421.com> wrote in message
news:ccgsca$juu$1@is.intellij.net...
I
>
standard
multiple
>
>
>
Excellent! I am pleased again as it does in fact do what I initially hoped
it would!
My bad.
- scott
"Amnon I. Govrin" <agovrin@freshwater.com> wrote in message
news:cch03a$ctn$1@is.intellij.net...
>
>
>
the
>
>
when
window,
text
too?
>
>