📜  红宝石 | StringScanner 获取字节函数

📅  最后修改于: 2022-05-13 01:55:07.690000             🧑  作者: Mango

红宝石 | StringScanner 获取字节函数

StringScanner#getbyte() : 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