Day21 心得体会&读书笔记

2017-05-24  本文已影响4人  柳辉

一、心得体会
1、今天完成了什么?

2、今天收获了什么?

while i < a.length
  (0...(a.length-i)).each do |j|
    a[j], a[j+1] = a[j+1], a[j] if a[j] < a[j+1]
  end
  i += 1
end
def isTrangle(a, b, c)
  if a + b > c && a + c > b && b + c > a
    puts "It is a trangle!"
  end
end
def test
   puts "You are in the method"
   yield
   puts "You are again back to the method"
   yield
end
test {puts "You are in the block"}

显示结果:

You are in the method
You are in the block
You are again back to the method
You are in the block

同时你还可以传参数到yield

def test
  yield 10
  puts "我是打酱油的"
  yield 100
end
test {|i| puts "我是打酱油的#{i}"}

结果长这样:

我是打酱油的10
我是打酱油的
我是打酱油的100

如果你想传更多的参数,可以这样:

yield a, b
test {|a, b| puts "我是打酱油的"}

你还可以这样:

def test(&block)
   block.call
end
test { puts "Hello World!"}

3、今天犯了哪些错误?

4、今天的状态如何?

5、明天还要做哪些工作?

二、读书笔记

一、Rails on Rack

Rack简介

Rack为使用Ruby开发的网页程序提供了小型模块化,适用性极高的接口。

Rack尽量使用最简单的方式封装HTTP请求和响应。

为服务器、框架和二者之间的软件(中间件)提供了统一的API,只要调用一个简单的方法就能完成一切操作。

上一篇 下一篇

猜你喜欢

热点阅读