Ruby: check if object is nil

前端 未结 3 982
轮回少年
轮回少年 2021-02-14 16:07
  def parse( line )
    _, remote_addr, status, request, size, referrer, http_user_agent, http_x_forwarded_for = /^([^\\s]+) - (\\d+) \\\"(.+)\\\" (\\d+) \\\"(.*)\\\" \\         


        
3条回答
  •  遥遥无期
    2021-02-14 16:36

    You seem to have a few questions here, so I'll take a stab at what seems to be the main one:

    If you want to see if something is nil, just use .nil? - so in your example, you can just say request.nil?, which returns true if it is nil and false otherwise.

提交回复
热议问题