Difference between “and” and && in Ruby?

前端 未结 7 1340
别跟我提以往
别跟我提以往 2020-11-22 09:28

What is the difference between the && and and operators in Ruby?

7条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 09:51

    I don't know if this is Ruby intention or if this is a bug but try this code below. This code was run on Ruby version 2.5.1 and was on a Linux system.

    puts 1 > -1 and 257 < 256
    # => false
    
    puts 1 > -1 && 257 < 256
    # => true
    

提交回复
热议问题