0

I have an interrogation about the Ok helper in play.api.mvc.Results.

When I do a:

def index = Action {
  Ok("Hello world!")
}

in a Play! controller, I am supposed to end up with a Result somehow. Am I not?

But all I can see in the api documentation is a val Ok: Status. My question is how can scala end up with a Result with an expression such as Ok("Hello world")?

Is there some apply called on Status somewhere? If no how is the Result returned from a simple val??

balteo
  • 23,602
  • 63
  • 219
  • 412
  • My question relates to the playframework api/implementation first and the link you provide does not really answer my question... Why is my question considered for closing?? – balteo Jan 06 '14 at 21:11
  • From the [answer](http://stackoverflow.com/a/1223913/406435): `it's just syntactic sugar whereby the compiler converts f(a) into f.apply(a) as a special syntax case`. In you case `Ok("Hello world!")` means `Ok.apply("Hello world!")`. – senia Jan 06 '14 at 21:12
  • Then you confirm that Ok is of type Status? – balteo Jan 06 '14 at 21:14
  • 2
    Yes, since `def index` is part of some `class`/`object` that extends `Controller` it should be a field `Ok` of `Controller`. And yes, it has type `Status` with `apply` method. – senia Jan 06 '14 at 21:18

0 Answers0