in reply to Re: Best practices for warnings about wrong context
in thread Best practices for warnings about wrong context

there is no way using the return of wantarray could ever make sense as a body
Of course it makes sense. It prints "1" as body, means wantarray returns TRUE. This function is for PoC purpose.
  • Comment on Re^2: Best practices for warnings about wrong context

Replies are listed 'Best First'.
Re^3: Best practices for warnings about wrong context
by Your Mother (Archbishop) on Oct 05, 2015 at 16:50 UTC

    It does not. The body expects a string/scalar. $c->response->body(defined wantarray); prints "1". Maybe I am missing the point because a setter like ->body expects a value and is therefore never going to be a void context call; it's a strange question / concept to want to demonstrate.

      In this example wantarray returns context in which the action called, not related to what body expects, so
      $c->response->body(wantarray)
      same as
      my $x = wantarray; $c->response->body($x)

        Sorry, you are quite right about that. I was talking crazy. It still does not print "1" though, as you're right, same wantarray context so nothing could be different, but returns false but defined.