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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:35:45+00:00 2026-05-27T20:35:45+00:00

Is that return necessary? Let’s say it’s in the middle of an action. render(contentType:’text/json’,

  • 0

Is that return necessary? Let’s say it’s in the middle of an action.

render(contentType:'text/json', text: ['success': true] as JSON)    
return
  • 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-27T20:35:46+00:00Added an answer on May 27, 2026 at 8:35 pm

    If you don’t return, any code after render will also be executed, which is often not what you want, e.g.

    def someAction = {
    
      if (someCondition) {
        render view: 'success'
        // if we don't return execution would fall through to the code below
        return  
      }
    
      log.error 'something went wrong'
      render view: 'error'
    }
    

    Of course, if you use this style instead, there’s no need to return

    def someAction = {
    
      if (someCondition) {
        render view: 'success'
    
      } else {    
        log.error 'something went wrong'
        render view: 'error'
      }
    }
    

    If an action only has one exit point, there’s no need to return after render

    def someAction = {
        render view: 'success'
    }
    

    Just remember that the code after render will be executed if you don’t return.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can somebody tell me why compiler thinks that break is necessary after yield return
i have an action that return a file content. i added: Response.AddHeader(Content-Disposition, attactment; filename:\
I have a method that return a complex JSON object. It's a heavy processing
I am calling a service that return JSON data. Script: $.ajax({ type: "POST", url:
how do i code a python program that return a json element that look
Let's say I have an ASP.NET MVC webapp that calls a repository layer, which
Let's say I have a javascript method that takes a little to long to
Let say that we have the following query: SELECT DISTINCT COUNT(`users_id`) FROM `users_table`; this
I have a function that return [[]] , and I want to test the
I know that the C++ standard says that return 0 is inserted at the

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.