From: Robert Klemme Date: 2007-09-04T23:15:40+09:00 Subject: Re: Feeding a codeblock/function with an array or something similar? 2007/9/4, kazaam : > Hi, > I have a codeblock like this: > > def foobar(command,customerrormessage) > if not system(command) > puts customerrormessage > exit > end > end > > > and then many calls of it like: > > foobar('rm something','Error I could'nt remove something') > foobar('apt-get install thishere','Error while installing the packet') > foobar('module-assistant a-i mymodule','Error while installing the module') > [..] > > In pascal I would simply create a multi-dimensional array[x,y] and fill it with the commands and the corresponding error-messages but how to do this in ruby? There are no arrays like the mentioned on or? Or do you have a even better solution for this? You can create multidimensional array just the same: [ ['rm something','Error I could'nt remove something'], ['apt-get install thishere','Error while installing the packet'], ['module-assistant a-i mymodule','Error while installing the module'], ].each do |cmd, error| unless system cmd $stderr.puts error exit 1 end end Kind regards robert