Ruby StringScanner getbyte函数
StringScanner#getbyte() : getbyte()是StringScanner类的一个方法,用于返回StringScanner上指针的字节数。
语法。StringScanner.getbyte()
参数。StringScanner的值
返回:StringScanner上指针的字节数。
例子 #1 :
# Ruby code for StringScanner.getbyte() method
# loading StringScanner
require 'strscan'
# declaring StringScanner
c = StringScanner.new("Mon Sep 12 2018 14:39")
# getbyte() method
puts "String Scanner getbyte form : #{c.getbyte()}\n\n"
# getbyte() method
puts "String Scanner getbyte form : #{c.getbyte()}\n\n"
# getbyte() method
puts "String Scanner getbyte form : #{c.getbyte()}\n\n"
输出:
String Scanner getbyte form : M
String Scanner getbyte form : o
String Scanner getbyte form : n
例子 #2 :
# Ruby code for StringScanner.getbyte() method
# loading StringScanner
require 'strscan'
# declaring StringScanner
c = StringScanner.new("hellogeeks")
# getbyte() method
puts "String Scanner getbyte form : #{c.getbyte()}\n\n"
# getbyte() method
puts "String Scanner getbyte form : #{c.getbyte()}\n\n"
# getbyte() method
puts "String Scanner getbyte form : #{c.getbyte()}\n\n"
输出:
String Scanner getbyte form : h
String Scanner getbyte form : e
String Scanner getbyte form : l