Loading ...
Sorry, an error occurred while loading the content.
 

[OT] Ruby Question

Expand Messages
  • Chris Wheeler
    Hi, I have a question about some syntax I saw someone use here on the list ( I can t find the post,so I am going from memory) Someone said that you could do
    Message 1 of 6 , Aug 26, 2005
      Hi,

      I have a question about some syntax I saw someone use here on the list ( I
      can't find the post,so I am going from memory)

      Someone said that you could do this:

      actualValue shouldBeEqualTo: expectedValue

      Could someone explain this way of declaring a method to me, please? I'd
      search for it, but I don't really know what you call that in Ruby. I'm still
      learning this language, and am not clear on how you make that happen in
      Ruby, and I'd desperately like to be able to do it.

      Thanks,

      Chris.


      --
      ---------------------
      Chris Wheeler
      Extreme Programmer & Coach
      Visit my new site! http://www.agilelectric.com


      [Non-text portions of this message have been removed]
    • Randy Coulman
      ... This looks like Smalltalk syntax to me, not Ruby. Methods of this form are called keyword messages in Smalltalk. Randy -- Randy Coulman
      Message 2 of 6 , Aug 26, 2005
        On 8/26/05, Chris Wheeler <christopher.wheeler@...> wrote:
        >
        > Someone said that you could do this:
        >
        > actualValue shouldBeEqualTo: expectedValue
        >
        > Could someone explain this way of declaring a method to me, please? I'd
        > search for it, but I don't really know what you call that in Ruby. I'm still
        > learning this language, and am not clear on how you make that happen in
        > Ruby, and I'd desperately like to be able to do it.
        >

        This looks like Smalltalk syntax to me, not Ruby. Methods of this
        form are called "keyword messages" in Smalltalk.

        Randy
        --
        Randy Coulman
        rcoulman@...
      • buzdin
        I doubt that this is Ruby code. I have not met such a syntax not in books not in the actual code. ... list ( I ... I m still
        Message 3 of 6 , Aug 26, 2005
          I doubt that this is Ruby code.
          I have not met such a syntax not in books not in the actual code.

          > Hi,
          >
          > I have a question about some syntax I saw someone use here on the
          list ( I
          > can't find the post,so I am going from memory)
          >
          > Someone said that you could do this:
          >
          > actualValue shouldBeEqualTo: expectedValue
          >
          > Could someone explain this way of declaring a method to me, please? I'd
          > search for it, but I don't really know what you call that in Ruby.
          I'm still
          > learning this language, and am not clear on how you make that happen in
          > Ruby, and I'd desperately like to be able to do it.
          >
          > Thanks,
          >
          > Chris.
        • Chris Wheeler
          ... Thanks for the pointer. I saw code like this on Dave Astels site where he says: In Smalltalk, and likely Ruby, this can be even more natural if we embed
          Message 4 of 6 , Aug 26, 2005
            >
            > This looks like Smalltalk syntax to me, not Ruby. Methods of this
            > form are called "keyword messages" in Smalltalk.
            >


            Thanks for the pointer. I saw code like this on Dave Astels site where he
            says:

            In Smalltalk, and likely Ruby, this can be even more natural if we embed the
            framework into the class library (a common approach in Smalltalk btw). You
            could write something like: *actual shouldEqual: expected* or *result
            shouldBeNull* or *[2 / 0] shouldThrow: DivideByZeroException*.

            I thought that meant this was possible in Ruby.

            That in mind, I do see this in Rails:

            scaffold: someScafoldName

            What does the ':' mean? Is this a method call?

            Chris.
            --
            ---------------------
            Chris Wheeler
            Extreme Programmer & Coach
            Visit my new site! http://www.agilelectric.com


            [Non-text portions of this message have been removed]
          • Randy Coulman
            ... It might be, but I don t know Ruby. All you need is the ability to add methods to existing classes (called loose methods in Smalltalk). If Ruby lets you
            Message 5 of 6 , Aug 26, 2005
              On 8/26/05, Chris Wheeler <christopher.wheeler@...> wrote:
              >
              > Thanks for the pointer. I saw code like this on Dave Astels site where he
              > says:
              >
              > In Smalltalk, and likely Ruby, this can be even more natural if we embed the
              > framework into the class library (a common approach in Smalltalk btw). You
              > could write something like: *actual shouldEqual: expected* or *result
              > shouldBeNull* or *[2 / 0] shouldThrow: DivideByZeroException*.
              >
              > I thought that meant this was possible in Ruby.
              >

              It might be, but I don't know Ruby. All you need is the ability to add
              methods to existing classes (called "loose methods" in Smalltalk). If
              Ruby lets you do that, then you can use the same technique there.

              > That in mind, I do see this in Rails:
              >
              > scaffold: someScafoldName
              >
              > What does the ':' mean? Is this a method call?
              >

              Not a clue, sorry.

              Randy
              --
              Randy Coulman
              rcoulman@...
            • Bill Kelly
              From: Chris Wheeler ... Any possibility it was scaffold :someScaffoldName ? An identifier with a leading : is a Symbol, ...
              Message 6 of 6 , Aug 26, 2005
                From: "Chris Wheeler" <christopher.wheeler@...>
                >
                > That in mind, I do see this in Rails:
                >
                > scaffold: someScafoldName
                >
                > What does the ':' mean? Is this a method call?

                Any possibility it was

                scaffold :someScaffoldName

                ?

                An identifier with a leading : is a Symbol, ... an
                immutable, unique string.

                Symbols can also be created from String objects.

                :foo is the same as "foo".intern


                Hope this helps, (leaving on trip... back next week)

                Regards,

                Bill
              Your message has been successfully submitted and would be delivered to recipients shortly.