Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
@blacktulip
高级会员
第 207 位会员 / 2011-11-23

117 篇帖子 / 2599 条回帖
40 关注者
0 正在关注
4 收藏
GitHub Public Repos
  • octopress-theme-yinyang 37

    YinYang (陰陽) is a minimal, responsive theme for Octopress.

  • vimfiles 1

    My vimfiles

  • qingwang.github.com 0

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 第 0 次南京聚会小结 at 2013年06月30日

    #22 楼 @yedingding 能详细说说 pragmatic 和 asana 的不同之处么?我看了 http://blog.pragmatic.ly/ripoff-asana-we-say-no-and-why-were-here/ 但是没有什么细节内容

  • Ruby 1.8.7 这会真的退休了。 at 2013年06月30日

    #5 楼 @hooopo 咦,已经有人都补上了啊,哈哈

  • 刚学 ROR 开发 不懂 CSS 不知道这是神马问题 rails 4.0 at 2013年06月30日

    #4 楼 @yangjie6020 这代码没有 carts 的路由啊...

  • Ruby 1.8.7 这会真的退休了。 at 2013年06月30日

    #5 楼 @hooopo 既然你这么说... 我去每天弄一点弄一点吧...

  • 第 0 次南京聚会小结 at 2013年06月30日

    #4 楼 @iBachue 培养什么的当然只是培养兴趣而已,培养技能是不可能的,靠谱序员都是自学出来的

  • Ruby 1.8.7 这会真的退休了。 at 2013年06月30日

    #3 楼 @hooopo 其实我都 fork 了一个 www.ruby-lang.org 打算做点贡献... 但是仔细一看落下的进度实在太多了,感觉做不完 -_-||

  • Ruby 1.8.7 这会真的退休了。 at 2013年06月30日

    This is very disturbing English … machine translation?

  • Nitrous.io 开放公测,在「云」里创建开发环境 at 2013年06月30日

    #25 楼 @hhuai 80/443 端口开着?有公网 IP?

  • 是不是应该来个总结帖什么的? at 2013年06月30日

    对什么暗号呢你们俩...

  • 下厨房丢了 2 个月 的数据 at 2013年06月30日

    #18 楼 @zealinux rubychina 只是个 hobby forum .. 下厨房是商业公司,这能一样么...

  • Nitrous.io 开放公测,在「云」里创建开发环境 at 2013年06月30日

    #23 楼 @hhuai 又不是做网站为什么要绑域名……

  • Zeal: 离线 API 文档浏览 + 搜索工具 at 2013年06月30日

    #8 楼 @Peter 仔细看贴

  • 查看你常用的 10shell 命令? at 2013年06月29日

    #7 楼 @luikore 是 git 么

  • 一个 rails model 的方法求美化 at 2013年06月29日

    我也觉得这样写很正常..

  • 一个 rails model 的方法求美化 at 2013年06月29日

    #3 楼 @wuwx 额我搞错了... sorry

  • 一个 rails model 的方法求美化 at 2013年06月29日

    这个写法感觉有点问题... 如果账户下只会有一条有效账单的话,最后的 .first 就多余;如果账户可以有不止一条有效账单,那 .first 就只能返回一条。

    噢,我搞错了,是用来把 Relation 转成 Invoice 的 ...

  • 查看你常用的 10shell 命令? at 2013年06月29日

    怪了,我怎么会 rake 这么多呢...

  • 蝉游记王益善专访:7 人小团队创造 App 30 万下载量 at 2013年06月29日

    #26 楼 @quakewang 希望能给个选择... 藏很深很角落让普通用户看不到就好了

  • 想选择一个 JavaScript 框架真难 at 2013年06月29日

  • Ruby 中怎么替换 setattr (...) at 2013年06月29日

    http://stackoverflow.com/questions/2136380/ruby-equivalent-of-python-setattr

    Either obj.instance_variable_set("@instance_variable", value) or obj.send("instance_variable=", value).

  • 蝉游记王益善专访:7 人小团队创造 App 30 万下载量 at 2013年06月29日

    #16 楼 @quakewang 这是出于什么考虑呢?我还是喜欢邮件直接注册

  • 我现在要转行了 at 2013年06月29日

    #104 楼 @gazeldx 为啥做咨询师.. 做私募算了

  • 蝉游记王益善专访:7 人小团队创造 App 30 万下载量 at 2013年06月29日

    我想知道怎么注册账号……网站和 app 里都找不到

  • [北京][EMC] Sr. Developer Engineer for testing cloud in BRS at 2013年06月29日

    最后的「喜欢」是什么意思啊?

  • 蝉游记王益善专访:7 人小团队创造 App 30 万下载量 at 2013年06月28日

    膜拜。

  • 怒了,这回 bcrypt-ruby 又出问题了 at 2013年06月28日

    #28 楼 @luikore 哇哈哈,用这邮箱一搜索就发现你在 github 上有几个 repo 里面还有这信息呢

  • 还有高手给详细的解释下 caller [1..-1] 啊 at 2013年06月28日

    我不是高手啊,就是初学者,刚知道有这么个 API,翻了下文档:

    Returns the current execution stack---an array containing strings in the form "file:line" or "file:line: in `method'". The optional start parameter determines the number of initial stack entries to omit from the result.
    
    Returns nil if start is greater than the size of current execution stack.
    

    我的理解是这样的...

    比如说现在有个 test.rb 文件,里面是三个嵌套调用的 method 和几个最外层 method 调用 (照抄文档)

    def a(skip)              # line 1
      caller(skip)           # line 2
    end                      # line 3
    def b(skip)              # line 4
      a(skip)                # line 5
    end                      # line 6
    def c(skip)              # line 7
      b(skip)                # line 8
    end                      # line 9
    c(0)   # line 10 => ["test.rb:2:in `a'", "test.rb:5:in `b'", "test.rb:8:in `c'", "test.rb:10:in `<main>'"]
    c(1)   # line 11 => ["test.rb:5:in `b'", "test.rb:8:in `c'", "test.rb:11:in `<main>'"]
    c(2)   # line 12 => ["test.rb:8:in `c'", "test.rb:12:in `<main>'"]
    c(3)   # line 13 => ["test.rb:13:in `<main>'"]
    c(4)   # line 14 => []
    c(5)   # line 15 => nil
    

    第 10 行运行时,代码执行次序是 line 10 -> line 8 -> line 5 -> line 2,在 line 2 遇到了 caller method,于是就把这个执行 stack 给放在一个数组里面 return 出来了,数组排序是执行次序反过来。

    第 11 行运行时,代码执行次序是 line 11 -> line 8 -> line 5 -> line 2,在 line 2 遇到了 caller method,于是又把这个执行 stack 给 return 出来,但是 11 行传进去的参数是 1,所以第一个元素 (应该是 "test.rb:2:ina'"` 就被忽略掉了。

    以下类推...

    回到楼主的问题,如果在 test.rb 的最后添加一句

    ......
    c(1..-1)  # line 16
    

    会 return 什么呢?

    推测:第 16 行运行时,代码执行顺序是 line 16 -> line 8 -> line 5 -> line 2,在 line 2 遇到 caller method , 此时把 stack 放进数组 return 出来。完整的数组应该是:

    ["test.rb:2:in `a'", "test.rb:5:in `b'", "test.rb:8:in `c'", "test.rb:16:in `<main>'"]
    

    但是传入了一个 range : 1..-1 ,这个 range 其实就是去掉数组的第一个元素 (index 0)

    所以推测最后结果应该是:

    ["test.rb:5:in `b'", "test.rb:8:in `c'", "test.rb:16:in `<main>'"]
    

    经测试正确...

  • 这个 if a = b && c ... end 语法代表什么意思呢? at 2013年06月28日

    测试了下 data = a && b 的执行顺序是 data = (a && b) 而不是 (data = a) && b 。这样就和 #2 楼 实际情况一致了。

  • 这个 if a = b && c ... end 语法代表什么意思呢? at 2013年06月28日

    #3 楼 @goinaction 赋值操作不可能失败的

  • 这个 if a = b && c ... end 语法代表什么意思呢? at 2013年06月28日

    瞎猜 ing ... 判断 session['devise.googleapps_data'] 以及session['devise.googleapps_data']['user_info'] 都不是 nil 吧,顺便把 session['devise.googleapps_data'] 赋值给 data ?

  • 上一页
  • 1
  • 2
  • …
  • 53
  • 54
  • 55
  • 56
  • 57
  • …
  • 83
  • 84
  • 下一页
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English