Ruby/Statement/throw
Материал из Wiki.crossplatform.ru
Версия от 18:00, 13 сентября 2010; ViGOur (Обсуждение | вклад)
throw a symbol out
#!/usr/bin/env ruby def limit( n ) puts n throw :done if n <= 0 limit( n-1 ) end catch( :done ) { limit( 5 ) }
throw sends a message to catch if n is less than or equal to 0.
#!/usr/bin/env ruby def limit( n ) puts n throw :done if n <= 0 limit( n-1 ) end catch( :done ) { limit( 5 ) }