If I understood what you are trying to get.

[1,2,3].each {|x| p x, begin x/0; rescue; end; }

will puts the original value and nil (because that is what rescue returns).

For example if you want to put 0 when a division is not possible (raises
exception) try this:

[1,2,3].each {|x| p x, begin x/0; rescue; 0 end; }

Hope this helps.

On 7 March 2017 at 19:31, Hugo Leonel Angelo <hugoangelo / gmail.com> wrote:

> try this
>
> [1,2,3].each {|x| begin p x, x/0; rescue; end; }
>
> On 7 March 2017 at 19:29, Robert Klemme <shortcutter / googlemail.com>
> wrote:
>
>> On Tue, Mar 7, 2017 at 7:29 PM, Die Optimisten
>> <inform / die-optimisten.net> wrote:
>>
>> > begin [1,2,3].each {|x| p x, x/0 };  rescue; end
>> > # this ends after the first error, I want it to continue till the end,
>> > ignoring all errors inside
>> > What to change, what is wrong?
>>
>> The placement of "rescue". ;-)
>>
>> robert
>>
>> --
>> [guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
>> - without end}
>> http://blog.rubybestpractices.com/
>>
>> Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
>> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>>
>
>
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>