I came across the following code and couldn't figure out what was going on.
def self.eof_packet?(data)
data[0] == ?\xfe && data.length == 5
end
I came across the following code and couldn't figure out what was going on.
def self.eof_packet?(data)
data[0] == ?\xfe && data.length == 5
end
It's a hexadecimal character literal. You can also use 0xfe
, which also works for larger numbers (e.g. 0x100
) that don't fit in a byte.