开发者

What's this _n_ Ruby koans?

I'm trying o开发者_如何学运维ut Ruby koans and found some tests using this _n_ , never seen it before what is it and how do I use it?

Example:

def test_objects_have_methods
           fido = Dog.new
           assert fido.methods.size > _n_
end

// John


Found it:

 # Numeric replacement value.
    def _n_(value=999999, value19=:mu)
      if RUBY_VERSION < "1.9"
        value
      else
        (value19 == :mu) ? value : value19
      end
    end


It's just a variable. Variable names in ruby can use underscores (even at fist and last positions). Try ctrl-clicking it in your IDE and you'll probably see its declaration.


Are you sure that _n_ isn't one of the "fill in the blanks" parts?


it is just another blank that needs to be filled. just replace n with right number of methods (for ex, 0 ) to solve this assertion error in your ruby koans. let me know if it works

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜