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

  • Home
  • SEARCH
  • 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 518903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:59:06+00:00 2026-05-13T07:59:06+00:00

Hi I have a strange situation here: # Is there a semantic difference between

  • 0

Hi I have a strange situation here:

# Is there a semantic difference between these 2 in ruby?


class MyClass < ClassThatExtendsActiveRecordBase

...

# code snippet A:

  def image_width(size); self.image.width(size); end

# vs code snippet B

  def image_width(size)
    self.image.width(size)
  end

end

I have a situation where code snippet A didn’t appear to be recognised as a function
but when I modify A by substituting semicolons with return chars to produce B the methods are recognised (this is ruby 1.8.7)

Is anyone able to help me understand what is happening that this occurs?

  • 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-13T07:59:07+00:00Added an answer on May 13, 2026 at 7:59 am

    Is there a semantic difference between these 2 in ruby?

    There shouldn’t be. And there isn’t, at least with the versions I have tested:

    • YARV 1.9.2 Snapshot ruby 1.9.2dev (2010-01-02 trunk 26229) [i686-linux]
    • YARV 1.9.1p243 ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
    • MRI 1.8.7p174 ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux]
    • MRI 1.8.6p383 ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]
    • JRuby 1.5 Snapshot (1.9 mode) jruby 1.5.0.dev (ruby 1.9.2dev trunk 24787) (2009-11-02 6586) (Java HotSpot(TM) Client VM 1.7.0-ea) [x86-java]
    • JRuby 1.5 Snapshot (1.8 mode) jruby 1.5.0.dev (ruby 1.8.7 patchlevel 174) (2009-11-02 6586) (Java HotSpot(TM) Client VM 1.7.0-ea) [x86-java]
    • JRuby 1.4.0 (1.9 mode) jruby 1.4.0 (ruby 1.9.2dev trunk 24787) (2009-11-02 69fbfa3) (Java HotSpot(TM) Client VM 1.7.0-ea) [x86-java]
    • JRuby 1.4.0 (1.8 mode) jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) Client VM 1.7.0-ea) [x86-java]
    • JRuby 1.3.1 (1.9 mode) jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot(TM) Client VM 1.6.0_14) [i386-java]
    • JRuby 1.3.1 (1.8 mode) jruby 1.3.1 (ruby 1.9.1p0) (2009-06-15 2fd6c3d) (Java HotSpot(TM) Client VM 1.6.0_14) [i386-java]
    • IronRuby IronRuby 0.9.1.0 on .NET 4.0.0.0
    • IronRuby IronRuby 0.9.2.0 on .NET 2.0.0.0

    Since the code example you posted is incomplete and doesn’t even parse correctly, I used a slightly modified version to test:

    class C < Object
      def semicolon(arg); self.foo(arg); end
    
      def newlines(arg)
        self.foo(arg)
      end
    
      def really_short(arg) foo(arg) end
    
      def foo(arg) arg end
    end
    
    require 'test/unit'
    class TestMethodDefinition < Test::Unit::TestCase
      def test_that_semicolons_work
        assert_equal :foo, C.new.semicolon(:foo)
      end
      def test_that_newlines_work
        assert_equal :foo, C.new.newlines(:foo)
      end
      def test_that_really_short_definitions_work
        assert_equal :foo, C.new.really_short(:foo)
      end
    end
    

    You wrote

    […] didn’t appear to be recognised as a function

    What do you mean by that? There is no such thing as a function Ruby, so the fact that functions don’t work shouldn’t really be surprising.

    Also, what do you mean by “recognised”? This word has a very specific meaning in programming, but you don’t appear to be using it with that meaning.

    And lastly, what does it mean that it “appears” to not work? Does it or doesn’t it work?

    Could you provide a complete and minimal testcase that exhibits the behavior you are seeing? Also, please describe:

    • what is the behavior you are expecting
    • why you think that behavior should occur
    • what is the behavior you are actually observing
    • what are the precise error messages you are getting

    At the moment, it looks like a very subtle bug in your specific installation of Ruby.

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

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer how to deploy my app Netbeans on build operation creates… May 16, 2026 at 9:09 am
  • Editorial Team
    Editorial Team added an answer Str pointes to a fixed string. You are modifying it… May 16, 2026 at 9:09 am
  • Editorial Team
    Editorial Team added an answer This result set contains multiple orders, this would require a… May 16, 2026 at 9:09 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Hallo everybody, I'm dealing with a pretty strange situation here. I have developed a
I have a pretty weird situation here, and i came up with a very
I've got a strange situation where deleting and creating directories in quick succession on
This may seem strange... but I'm wondering if there is anyway to make a
I've recently encountered an odd situation when computing the hash Code of tuples of
We have a MFC 8 application compiled with /CLR that contains a larger amount
I have a minified/packed javascript file which is causing problems. The issue is that
Let's say I have some Control that has been disabled. It contains a bunch
I found out really strange behavior on relatively simple use case, probably I can't

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.