[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: pass block to a method call?

e

1/30/2005 12:36:00 AM

Jeff Davis wrote:
>> The only difference is that in the second case the block is anonymous.
>> In the first case, it has a name and so you can pass it around if you
>> want (e.g. recursively).
>>
>>
>>
> That brings up another question: how do you call a function that accepts
> a block if all you have is a proc object?

Prepend the Proc with a &.

def foo()
yield
end

bar = proc { puts 'foo' }
foo bar # Error
foo &bar # OK

> i.e. what's the difference between the following:
> def foo(&p) p.call; end
> foo { puts 'foo' }
> and:
> def foo(&p) p.call; end
> p = proc { puts 'foo' }
> foo { p.call }
>
> Are those the same? Is the latter the proper way to pass a proc object
> as a block?

See above :)

> Thanks to all for your help. I'm just getting into Ruby and I really
> like it so far (coming from Python/Perl/PHP).
>
> Regards,
> Jeff Davis

E



1 Answer

Kornet / Yaako Warrior from AUZ, Korea, Germany, RSA, USA, Sweden, Hong Kong, Canada, Russia, China,

8/27/2010 3:29:00 PM

0

TERRORISM AND THE ECONOMY

How the War on Terror is Bankrupting the World

Loretta Napoleoni, Interview with Philip Adams Thusday 10pm
http://www.abc.net.au/rn/latenightlive/stories/2010/2...
http://www.abc.net.au/rn/latenightlive/d...
Audio will be available after the interview
.
Economist and best-selling author Loretta Napoleoni traces the link
between the finances of the war on terror and the global economic
crisis, finding connections from Dubai to London to Las Vegas that
politicians and the media have at best ignored.
.
In launching military and propaganda wars in the Middle East,
America overlooked the war of economic independence waged by Al-Qaeda.
.
The Patriot Act boosted the black market economy, and the war on
terror prompted a rise in oil prices that led to food riots and
distracted governments from the trillion-dollar machinations of Wall
Street.
.
Consumers and taxpayers, spurred by propaganda fears, were lured into
crushing global debt.

Napoleoni shows that if we do not face up to the many serious
connections between our response to 9/11 and the financial crisis, we
will never work our way out of the looming global recession that now
threatens our way of life.

While we feared that Al-Qaeda might destroy our world, Wall Street
ripped it apart.
http://cost...
.
link to her new book
http://lorettanapo...
.
There's a strong push now, particularly with a new Australian
government set to depend on the support of independents and a Green
MP, for parliament to debate the Afghan deployment.
.
One of the independents is Andrew Wilkie, a former Australian
intelligence officer who resigned very publicly before the invasion of
Iraq, denouncing the reasons for that war.

WILKIE: We certainly do need a debate about why we're there. And one
of the great lies, one of the big lies of this federal election
campaign, a lie told by both the Labor Party and the Liberal Party, is
that we have to be there to fight terrorists for Australia's national
security.

MOTTRAM: He argues it was the US failure to finish the Afghanistan job
in 2002 that means fighting is still going on there. But he says
there's no easy solution.

WILKIE: It is clear that on one hand there needs to be foreign forces
in Afghanistan to create the stability to allow the government to
establish itself but on the other hand its the very presence of those
forces which is fuelling this ongoing war, mostly by nationalists not
by terrorists. Ultimately, we have to get out as quickly as we can and
let Afghanistan find its own natural political level .
.

Mr Wilkie A former Duntroon cadet, he rose to the rank of Lieutenant
Colonel and worked for United States defence giant Raytheon.

.

He continued his defence career as an intelligence analyst with the
Office of National Assessment.

.

But he caused a huge storm in 2003 when he resigned and spoke out
against the Howard government on the Iraq war, saying there was no
intelligence to indicate Saddam Hussein had weapons of mass
destruction.

.

Dr Peter Bowden from Whistleblowers Australia says Mr Wilkie is a
hero.

"Andrew Wilkie is a person I admire tremendously," he said.
http://www.abc.net.au/news/stories/2010/08/26/2...

.

"He undertook to release to the Australian people the information that
he had acquired through his work with the Office of National
Assessments, that there were no weapons of mass destruction in Iraq,
so our reasons for going to war there were close to zilch."

http://www.radioaustralia.net.au/connectasia/stories/201008/s2...
.
Share this message from here
https://docs.google.com/Doc?docid=0AVpOXG2fYkS8ZGNnazl0N3BfNDczZzcyZm1qY3c...