26
Aug

def comic(cast)
   cast.each do |character|
      unless character.is_a?(Array)
         yield(character)
      else
	 comic(character) {|x| yield x}
      end
   end
end

This method takes an array as argument and checks each element if it is an Array.
If the element is not an Array then the block is called.
If the element is an Array then the same method is called with that element as an argument and with the same block.

Now let’s look how we can call this method.

names = ['lucky luke', 'jolly jumper', 'rin tin tin', ['joe', 'william','jack', 'averell']]
comic(names) {|c| puts c}

Output :

lucky luke
jolly jumper
rin tin tin
joe
william
jack
averell

24
Aug

<body>
   <div id='main'>
      Main Div
   </div>
</body>

render :update do |page|
   page << "if ($('main')){"
   page.replace_html 'main', :inline => 'Here it is'
   page << "}"
end

This ruby code checks if there is a DOM object that its id = “main”.
If there is then changes its content to “Here it is”, if there is not do nothing.