Method: String#hex

Defined in:
lib/source/ruby.rb

#hexObject

call-seq:

str.hex -> num

Treats leading characters from str as a string of hexadecimal digits (with an optional sign and an optional 0x) and returns the corresponding number. Zero is returned on error.

'0x0a'.hex      #=> 10
'-1234'.hex     #=> -4660
'0'.hex         #=> 0
'abcdef'.hex    #=> 0


5639
5640
5641
5642
# File 'lib/source/ruby.rb', line 5639

def hex
  `var result=parseInt(this.__value__,16)`
  return `result.toString()=='NaN'?0:result`
end