Skip to main content

Some Doubts

6 replies [Last post]
ramon_lopes
Offline
Joined: 2007-04-20
Points: 0

Hi folks,

I'm getting started my studies about JavaFx, then I'm trying make little things but I'm having some problems.
This code bellow:

import javafx.ui.*;
import java.lang.*;

var nums = [1,2,3,4];
var numsGreaterThanTwo = nums[. > 2]; <= Here

When I compile it, appears: incompatible types: "expected Number, found Boolean in nums[<<.>> > 2] "
that references the instruction indicated above.

Thanks,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
pforhan
Offline
Joined: 2003-08-07
Points: 0

Unfortunately, the docs are a bit out-of-date. Try this instead:

----
var nums = [1,2,3,4];
var numsGreaterThanTwo = nums[x|x > 2];
println(numsGreaterThanTwo);

// some fun alternate ways to do the same thing:

var numsGreaterThanTwoAlso = select x from x in nums where x > 2;
println(numsGreaterThanTwoAlso);
var numsGreaterThanTwoThird = foreach (x in nums where x > 2) x;
println(numsGreaterThanTwoThird);
----

Pat.

Message was edited by: pforhan... fix syntax error

casperlw
Offline
Joined: 2008-03-28
Points: 0

thanks for the info, but how about the previous

list[indexof . > 0]

alexsch
Offline
Joined: 2007-07-12
Points: 0

Use [code] list[ elem | indexof elem > 0 ] [/code]

casperlw
Offline
Joined: 2008-03-28
Points: 0

thanks, but do you know why change that? Seems previous usage more convenient :(

alexsch
Offline
Joined: 2007-07-12
Points: 0

Chris Oliver sent out an e-mail listing the most recent changes to the JavaFX Interpreter. One of the changes was:

"Syntax changes: sequence indexing versus predicate is now distinguished syntactically. The . operator is now obsolete;"

See https://openjfx.dev.java.net/servlets/ReadMsg?listName=users&msgNo=863

casperlw
Offline
Joined: 2008-03-28
Points: 0

great thanks. :)