Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3874126
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:06:58+00:00 2026-05-19T22:06:58+00:00

In this blogpost by James Iry , he writes: Plus, Scala has an option

  • 0

In this blogpost by James Iry, he writes:

Plus, Scala has an “option” method that promotes a value to either Some(value) or None depending on whether it’s null or not …

I can’t seem to find this option method anywhere in the scaladoc.

Iulian Dragos‘s gdata client project contains a method that is probably what James was referring to.

def option[A <: AnyRef](a: A): Option[A] =
  if (a eq null) None else Some(a)

Please point out where can I find this method in the scaladoc.

P.S. I have a method that looks like this:

def permutations(s: String): List[String] = ...

I’m in 2 minds as to whether I should change it to:

def permutations(s: Option[String]): List[String] = ...

since the client can invoke it with null. Currently in the first instance, I expect a String parameter & I box it manually using the option method mentioned previously.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:06:59+00:00Added an answer on May 19, 2026 at 10:06 pm

    You can simply use the apply factory method on its companion object:

    scala> Option.apply("Test")                
    res51: Option[java.lang.String] = Some(Test)
    
    scala> Option.apply(null)  
    res52: Option[Null] = None
    

    … or the shorter version:

    scala> Option("Test")  
    res49: Option[java.lang.String] = Some(Test)
    
    scala> Option(null)
    res50: Option[Null] = None
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This blogpost and one of our senior developers at work believe that web development
This is my first post here and I wanted to get some input from
i use the git workflow as described in this blogpost . In short: everybody
i wonder what this query means: $blogPost = Doctrine_Query::create()->from('BlogPost p')->where('p.slug = ?', 'doctrine-released')->execute(); could
I have a blogpost edit page where you can either save your edits or
This is beyond both making sense and my control. That being said here is
I want to use a temp directory that will be unique to this build.
According to this blogpost on android developers blog it should be doable to change
[ edit : I've written a blogpost that explains everything in detail: look here
Hey guys, It's 5 am here, I was doing some code... when this came

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.