红宝石 | StringScanner 获取字节函数
StringScanner#getbyte() : getbyte()是一个 StringScanner 类方法,它返回 StringScanner 上指针的字节。
Syntax: StringScanner.getbyte()
Parameter: StringScanner values
Return: the byte of pointer on the 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