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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:02:18+00:00 2026-05-27T22:02:18+00:00

Which of these is better Ruby code formatting style, and why? Option A: def

  • 0

Which of these is better Ruby code formatting style, and why?

Option A:

def load_business
  @business ||= if params[:badge_uuid] 
    # some code
  else
    # some other code
  end
end

Option B:

def load_business
  @business ||= if params[:badge_uuid] 
                  # some code
                else
                  # some other code
                end
end
  • 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-27T22:02:19+00:00Added an answer on May 27, 2026 at 10:02 pm

    It’s a subjective question, so we can only give (hopefully reasoned) opinions. I always use option A. My rationale:

    1. The block of code is opened and closed at the same indentation-level, that creates a “visual cohesion”.

    2. If the variable name changes its size, you don’t need to edit anything (some text editors handle this automatically, though).

    3. You create a “hole” in the source code. The larger the variable name, the bigger the hole. IMO this is visually annoying. Also, you have less space available till reaching some reasonable 80/100-char limit.

    I use this style when writing multi-line hashes/arrays/… (note the comma also in the last element so we can re-order them easily and in diff-friendly way):

    hash = {
      :a => 1,
      :b => 2,
    }
    
    array = [
      :a, 
      :b,
    ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which of these two forms of Array Initialization is better in Ruby? Method 1:
I have some Ruby code which takes dates on the command line in the
I'm new to Ruby and am currently working on some practice code which looks
Which of these two platforms/ecosystems are better for writing web applications/websites? I am not
Which of these two statements is faster/better practice? myList.Where(x => { bool itemOne= x.ItemOne
Which of these pieces of code is faster? if (obj is ClassA) {} if
I am converting some php code into a Ruby script and I am attempting
Is there a better windows command line shell other than cmd which has better
Which way is better for removing float decimals places or is there a more
Is there any considerations to determine which is better practice for creating an object

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.