ruby 1.8 strange behavior

Ask a Question related to Ruby, Design and Development.

  1. #1

    Default ruby 1.8 strange behavior

    Hi,
    I've started making my own C extension to ruby, and found that strange
    behavior:
    class MyTest
    def []=(key,val)
    "my_own_return_value"
    end
    end
    test = MyTest.new
    p test[1] = "big"

    Both ruby1.6 and ruby1.7 puts "my_own_return_value", but ruby1.8 puts
    "big". I'm interested if this is right.
    I know that it's kinda stupid to do something like this and I found that just
    by accident, but anyway :)

    --
    sdmitry -=- Dmitry V. Sabanin
    MuraveyLabs.


    Dmitry V. Sabanin Guest

  2. Similar Questions and Discussions

    1. Strange behavior when trying to print
      Hi, on one of the mac at job i have a strange behavior . Mac is a Double Power G5, Tiger and In Design 3 When i want to print, if i have just...
    2. Strange behavior
      The problem seems to be in c code calling ruby calling c code. ======== start test.rb puts "about to require curses" require "curses" puts...
    3. Strange behavior of $.
      Apparently $. is not always set correct (see second ruby 1liner). Is this a bug? 12:12:42 : cat -n n 1 2 3 BAR="hello" 4 12:12:47 : ruby...
    4. DropDownList Strange Behavior
      I have several dropdownlist controls in a placeholder on my form. Certain events will show this place holder and populate the values of the items...
    5. Why strange IF...ELSE behavior
      Hi all, I'm getting a strange result with the following IF statement: $bar = ($foo == 'last') ? true : false; In my script $foo normaly has...
  3. #2

    Default Re: ruby 1.8 strange behavior

    >>>>> "D" == Dmitry V Sabanin <sdmitry@lrn.ru> writes:

    D> Both ruby1.6 and ruby1.7 puts "my_own_return_value", but ruby1.8 puts
    D> "big". I'm interested if this is right.

    The modification is intentional.


    Guy Decoux




    ts Guest

  4. #3

    Default Re: ruby 1.8 strange behavior

    On Fri, Sep 12, 2003 at 02:14:36AM +0900, Dmitry V. Sabanin wrote:
    > Hi,
    > I've started making my own C extension to ruby, and found that strange
    > behavior:
    > class MyTest
    > def []=(key,val)
    > "my_own_return_value"
    > end
    > end
    > test = MyTest.new
    > p test[1] = "big"
    >
    > Both ruby1.6 and ruby1.7 puts "my_own_return_value", but ruby1.8 puts
    > "big". I'm interested if this is right.
    > I know that it's kinda stupid to do something like this and I found that just
    > by accident, but anyway :)
    The rationale for that is making it work like an assignment:

    a = b[0] = 1
    # here you expect a == 1, not a = return value of []=

    Same thing for
    a = b.bla = 1

    --
    _ _
    | |__ __ _| |_ ___ _ __ ___ __ _ _ __
    | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
    | |_) | (_| | |_\__ \ | | | | | (_| | | | |
    |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
    Running Debian GNU/Linux Sid (unstable)
    batsman dot geo at yahoo dot com

    MSDOS didn't get as bad as it is overnight -- it took over ten years
    of careful development.
    -- [email]dmeggins@aix1.uottawa.ca[/email]

    Mauricio Fernández Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139