Note that there are some explanatory texts on larger screens.

plurals
  1. POType mismatch using Jedis in Scala
    primarykey
    data
    text
    <p>The following code produces four type mismatch errors. Why? In the first and second cases I'm doing a simple comparison with Strings. In the third case I'm assigning <code>false</code> to a var of type <code>Boolean</code>. In the final case I'm merely printing a stack trace!</p> <p>I am befuddled.</p> <p>The code:</p> <pre><code>//return TRUE if logged in def isLoggedIn(auth: String): Boolean = { val jedis = pool.getResource() var userid = jedis.get("auth:" + auth) var retVal = false try { if(userid != null) { //error here val userAuth = jedis.get("uid:" + userid + ":auth") if(userAuth == auth) { // error here retVal = true // error here } } } catch { case e =&gt; e.printStackTrace() //error here } finally { pool.returnResource(jedis) return retVal } } </code></pre> <p>The error:</p> <pre><code>[error] type mismatch; [error] found : Unit [error] required: Boolean [error] retVal = true // error here [error] ^ [error] type mismatch; [error] found : Unit [error] required: Boolean [error] if(userAuth == auth) { // error here [error] ^ [error] type mismatch; [error] found : Unit [error] required: Boolean [error] if(userid != null) { //error here [error] ^ [error] type mismatch; [error] found : Unit [error] required: Boolean [error] case e =&gt; e.printStackTrace() //error here [error] ^ [error] four errors found </code></pre> <p>I'm using Jedis 2.0.0 (https://github.com/xetorthio/jedis) to interface with a Redis DB. the Jedis.get() method returns <code>String</code>. I'm using sbt 0.10.1 and scala 2.9.0-1.</p> <p>What's going on?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload