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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:26:46+00:00 2026-05-23T22:26:46+00:00

In a helper I’ve got the code: signed_in? ? link_to(Sign out, signout_path, :method =>

  • 0

In a helper I’ve got the code:

signed_in? ? link_to("Sign out", signout_path, :method => :delete) : link_to("Sign in", signin_path)

However the same thing can be written:

if(signed_in?)
  link_to 'Sign Out', signout_path, :method => :delete
else
  link_to 'Sign In', signin_path
end

In the second case, the parens for the method call aren’t needed, in the first case they are. Why is that?

  • 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-23T22:26:47+00:00Added an answer on May 23, 2026 at 10:26 pm

    You don’t need parens when there is no ambiguity in the function calls. For instance:

      foo 1, 2 resolves to foo(1,2)
    

    and something like foo 1, bar 2 would be foo(1,bar(2)), but what about foo 1, bar 2, 3 that could go to either foo(1,bar(2,3)) or foo(1,bar(2),3)

    So in the last example you would need to put in the parens yourself to tell ruby what you actually want it to do.

    Also, if you ever want to call a method on the return value of the method you’ll need parens too
    i.e foo(1,2).bar

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

Sidebar

Related Questions

I am designing a helper method that does lazy loading of certain objects for
Looking for a nifty helper function/method for grepping through all defined tables, columns, stored
My helper code looks like this (and works fine btw): module ProvidersHelper def call_to_review(provider)
i have helper C functions in some Objective C classes. Just found out that
I have written a helper class which uses the Action - delegate as method
I've got a helper script for a Joomla 1.0 module I'm developing. I'm using
I'm writing a helper method for ASP.NET MVC and I need to call Url.Content
Is there a helper library out there for doing these types of date calculations
I have a helper method that calls two other helper methods, the problem is
I have a simple helper method in application_helper.rb that I am trying to test

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.