ivaneeo's blog

自由的力量,自由的生活。

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  669 Posts :: 0 Stories :: 64 Comments :: 0 Trackbacks
#############################################
##闭包的一个用法
animals = %w( ant bee cat dog elk ) # create an array
animals.each {|animal| puts animal } # iterate over the contents


#############################################
  def call_block
puts "Start of method"
yield ##执行传入的参数.这里为"In the block"
yield
puts "End of method"
end

call_block { puts "In the block" }

##############################################
posted on 2006-09-12 15:52 ivaneeo 阅读(250) 评论(0)  编辑  收藏 所属分类: ruby-宝石也锋芒

只有注册用户登录后才能发表评论。


网站导航: