HNHacker News
TopNewBestAskShowJobs

sedro

77 karma · joined April 21, 2016

submissionscomments
sedro··on Scala vs Go
You don't need to specify a return type in scala. In this case the return type is inferred as Option[Long].

You are correct about the exception if the cookie's value can't be parsed as a Long. You might instead write the code as:

  def getUserId()(implicit request: RequestHeader): Option[Long] = {
    request.cookies.get("uid")
      .flatMap(cookie => Try(cookie.value.toLong).toOption)
      .filter(_ > 0)
  }
or, equivalently:

  def getUserId()(implicit request: RequestHeader): Option[Long] = for {
    cookie <- request.cookies.get("uid")
    value <- Try(cookie.value.toLong).toOption if value > 0
  } yield value
sedro··on I cannot continue working on my add-ons
I'm with you. I was hooked on mouse gestures after using Opera 12. They came built into the browser, and you could tell. Gestures worked everywhere-- on a new tab, on a loading page, even on the browser window outside a tab.

Now I'm using Firefox plus a dozen extensions to poorly replicate a base Opera 12 installation. The e10s update already broke some FireGesture in some minor ways (e.g. wheel gestures scroll the page content now). Other extensions stopped working completely.

Time to give Vivaldi another shot...

sedro··on Comparison with Other Frameworks
Maybe, but be aware those are not equivalent (your method will pass extra arguments to RenderChild)
← PreviousPage 2 of 2