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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:00:20+00:00 2026-06-01T05:00:20+00:00

I like method parameters enclosed in parenthesis, this is some Pascal nostalgia. When cleaning

  • 0

I like method parameters enclosed in parenthesis, this is some Pascal nostalgia. When cleaning up code, if I find a method parameters without it I enclose them immediately.
Today it caused my working code throwing errors although my syntax looks okay according to the documentation.

Kernel.raise’s documentation has this format:

(Object) raise(exception[, string [, array]])

These are all working:

> raise TypeError
TypeError: TypeError

> raise (TypeError)
TypeError: TypeError

> raise "Error message"
RuntimeError: Error message

> raise ("Error message")
RuntimeError: Error message

But the enclosed version of the next throws syntax error:

> raise TypeError, "Error message"
TypeError: Error message

> raise (TypeError, "Error message")
SyntaxError: unexpected ')', expecting $end

I can live without it, I just want to know why this ends with an error.

  • 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-06-01T05:00:21+00:00Added an answer on June 1, 2026 at 5:00 am

    You probably already know that in idiomatic Ruby one would never insert a space between the end of a method and an argument list in parenthesis. Some style guides explicitly forbid it.

    There’s a pragmatic reason too.

    1.9.2-p290 > def concat(a, b)
    1.9.2-p290 >  a + b
    1.9.2-p290 > end
    
    1.9.2-p290 > concat 'foo', 'bar'
     => "foobar"
    1.9.2-p290 > concat('foo', 'bar')
     => "foobar"
    1.9.2-p290 > concat ('foo', 'bar')
    SyntaxError: (irb):27: syntax error, unexpected ',', expecting ')'
    

    You’ll encounter errors calling any method this way, not just Kernel.raise.

    I’m not familiar with Ruby internals, but I would imagine the reason for this is that when a space precedes the argument list, Ruby is expecting the “no-parens” style. So of course this works:

    1.9.2-p290 :035 > concat ("bar"), ("foo")
     => "barfoo"
    

    Presumably Ruby is trying to evaluate the contents of each parenthesized expression before passing the result to the method. I’d speculate that writing raise (TypeError, "Error message") is asking Ruby to evaluate just TypeError, "Error message", which of course fails.

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

Sidebar

Related Questions

In c# 4.0, are dynamic method parameters possible, like in the following code? public
How do you write a method/message with multiple parameters? EDIT: Like multiple parameters for
I have a Java method that takes 3 parameters, and I'd like it to
I wanna implement a javascript like method in java , is this possible ?
Does a method like this exist anywhere in the framework? public static void Swap<T>(ref
Is there a method like putAll() for dict in python? I did not find
I call the method like this: Headers: User-Agent: Fiddler Content-type: application/json Content-length: 116 Host:
Is there a kind of alternating params for method parameters? I like the keyword
I would like to retrieve the parameters's name of a method on MethodInterceptor class.
Say I have some method like so: public void Method<T>(Func<T> func) { ... }

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.