Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does ?\xfe mean in ruby?

Tags:

ruby

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
like image 470
Aaron Yodaiken Avatar asked Jul 15 '26 18:07

Aaron Yodaiken


1 Answers

? starts a character literal.

\x starts a hexadecimal escape.

like image 188
Ken Avatar answered Jul 18 '26 08:07

Ken



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!