jinkou2 jinkou2
jinkou2 jinkou2

Reputation: 1096

Type mismatch: expected Integer but was Float

I don't understand what i'm doing wrong here. I just copied/pasted a gist and adapt it to my case. (The reference gist is that given in graphgist : Movie recommendation )

Here is the gist. Neo4gist character's recommendation

The failed query is #5. It say's "type mismatch" but I don't know what to do to correct this.

Upvotes: 1

Views: 1412

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39926

I've reduced the problem down to this failing statement:

return reduce(y=0, b in [1,2,3] | y + b^2)

The result variable y of your REDUCE is initialized as a integer. It seems that b^2 internally creates a float, adding float to int and assigning the value back to a int fails.

There are two ways to work around:

1) initialize the variable as a float:

return reduce(y=0.0, b in [1,2,3] | y + b^2)

2) convert the result of square manually to a int:

return reduce(y=0, b in [1,2,3] | y + toInt(b^2))

Upvotes: 3

Related Questions