📜  红宝石 | StringScanner 指针函数

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

红宝石 | StringScanner 指针函数

StringScanner#pointer() : pointer()是一个 StringScanner 类方法,它返回扫描指针的字节位置

示例 #1:

# Ruby code for StringScanner.pointer() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("Mon Sep 12 2018 14:39")
  
# pointer() method
puts "String Scanner pointer form : #{c.pointer()}\n\n"
  
c.terminate()
# pointer() method
puts "String Scanner pointer form : #{c.pointer()}\n\n"

输出 :

String Scanner pointer form : 0

String Scanner pointer form : 21

示例 #2:

# Ruby code for StringScanner.pointer() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("hellogeeks")
  
  
# pointer() method
puts "String Scanner pointer form : #{c.pointer()}\n\n"
  
c.terminate()
# pointer() method
puts "String Scanner pointer form : #{c.pointer()}\n\n"

输出 :

String Scanner pointer form : 0

String Scanner pointer form : 10