Ask a Question related to Ruby, Design and Development.

  1. #1

    Default 'with' proposal

    Hello!

    Wouldn't something like this be cool?

    class Foo
    def read
    ...
    end
    def dump
    ...
    end
    def is_empty?
    ...
    end
    end

    f = Foo.new

    with f do
    read
    dump
    draw unless is_empty?
    end

    Regards,
    --
    University of Athens I bet the human brain
    Physics Department is a kludge --Marvin Minsky




    Elias Athanasopoulos Guest

  2. Similar Questions and Discussions

    1. Proposal for a new operator - .=
      OK so it's late, I'm not thinking straight, and I thought I'd post this. Proposal for a new operator - .= ================================ ...
    2. URGENT PROPOSAL
      MRS. EKI OMORODION #8 Queens Drive Ikoyi Lagos. Email:ekiomorodion670@netscape.net INTRODUCTION: l am Mrs. Eki Omorodion l know this proposal...
    3. INVESTMENT PROPOSAL
      This is a multi-part message in MIME format --dd1e7f93-6b57-489d-a349-90210943212c Content-Type: text/plain; charset=iso-8859-1...
    4. [PHP-DEV] Feature proposal
      I have to fight with people that using error suppression operator - they just hide their bugs. I wrote simple patch that allows set...
    5. Proposal system
      Am I beginning to develop a proposal system that will be types in the word, which would the best way of me be to interact with that problem, in...
  3. #2

    Default Re: 'with' proposal

    Hi --

    On Sun, 23 Nov 2003, Elias Athanasopoulos wrote:
    > Hello!
    >
    > Wouldn't something like this be cool?
    >
    > class Foo
    > def read
    > ...
    > end
    > def dump
    > ...
    > end
    > def is_empty?
    > ...
    > end
    > end
    >
    > f = Foo.new
    >
    > with f do
    > read
    > dump
    > draw unless is_empty?
    > end
    irb(main):007:0> class Foo; def talk; puts "hi"; end; end
    => nil
    irb(main):008:0> f = Foo.new
    => #<Foo:0x400b32a8>
    irb(main):009:0> f.instance_eval do talk end
    hi

    :-)


    David

    --
    David A. Black
    [email]dblack@wobblini.net[/email]


    David A. Black Guest

  4. #3

    Default Re: 'with' proposal

    On Sun, Nov 23, 2003 at 03:30:18AM +0900, David A. Black wrote:
    > irb(main):007:0> class Foo; def talk; puts "hi"; end; end
    > => nil
    > irb(main):008:0> f = Foo.new
    > => #<Foo:0x400b32a8>
    > irb(main):009:0> f.instance_eval do talk end
    > hi
    >
    > :-)
    Uber nice! Thanx. :-)

    Regards,
    --
    University of Athens I bet the human brain
    Physics Department is a kludge --Marvin Minsky




    Elias Athanasopoulos Guest

  5. #4

    Default Re: 'with' proposal

    Further:

    class Foo
    def talk
    puts "Hi."
    end
    end

    def with(obj, &blk)
    obj.instance_eval &blk
    end

    f = Foo.new

    with f do
    talk
    end


    - Dan



    Dan Doel Guest

  6. #5

    Default Re: 'with' proposal

    il Sun, 23 Nov 2003 03:26:38 +0900, Elias Athanasopoulos
    <elathan@phys.uoa.gr> ha scritto::
    >Hello!
    >
    >Wouldn't something like this be cool?
    >
    >with f do
    > read
    > dump
    > draw unless is_empty?
    >end
    >
    this is a faq:

    def with(obj, &blk)
    obj.instance_eval &blk
    end

    with 10 do
    puts to_s
    puts methods
    end
    gabriele renzi 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