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 8753527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:26:34+00:00 2026-06-13T13:26:34+00:00

Using Scala, in a Play 2.0 project, I am trying to grab data from

  • 0

Using Scala, in a Play 2.0 project, I am trying to grab data from a config file.

At present I use the following code to extract a String:

val foo = Play.current.configuration.getString("foo")

I had expected to get a String object back, but instead an Option[String] object is returned.

I cannot find any Java docs describing the Option[T] object and calling the toString() returns Some( foo ).

The same happens when using the configuration methods to extract Boolean and Int values from the config – ie, Option[Boolean] and Option[Int] are returned.

Can anyone explain what this Option[T] object is and how I can access the value I want in the form that the application method call implies it will be returned?

  • 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-06-13T13:26:35+00:00Added an answer on June 13, 2026 at 1:26 pm

    In scala, the type Option[T] represents an optional value of the type T. If you are used to Java terms, you could refer to an Option as ‘a value that might be null‘.

    In Play they are used when getting the configuration because the string might not be present – if you would try to read it using Java, it would return null.

    To get the config string you can use getOrElse, which lets you provide a default value in case the config string doesn’t exist:

    val foo = Play.current.configuration.getString("foo").getOrElse("bar")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Scala Play! framework with Anorm to persist the data model to the
I'm trying to test a model method using Play Framework 2.0 and Specs2. Global.scala
I'm using Play 2.0 with Scala and I'd like to extract some values that
I'm trying to use the Mailer plugin with my Play project and I've ran
I have the following code in Scala Play Framework: case class Step(name: String, f:
I just started working on a project using IntelliJ with Play and Scala plugins
I play a movie using the following code NSString *path = [[NSBundle mainBundle] pathForResource:@cobra
Im using play 2.0 and trying to modularize the project into a subproject. In
I'm new to Scala and our project mixes Java and Scala code together (using
Since Intellij does not yet support the Play-Scala-Template-Engine I was thinking about using plain

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.