Ruby StringScanner terminate函数
StringScanner#terminate() : terminate()是StringScanner类的一个方法,用于终止字符串指针。
语法。StringScanner.terminate()
参数。StringScanner的值
返回:终止字符串指针。
例子 #1 :
# Ruby code for StringScanner.terminate() method
# loading StringScanner
require 'strscan'
# declaring StringScanner
c = StringScanner.new("Fri Dec 12 1975 14:39")
puts (c.pos())
# terminate() method
c.terminate()
puts "String Scanner after terminate() : #{c.pos()}\n\n"
输出:
0
String Scanner after terminate() : 21
例子 #2 :
# Ruby code for StringScanner.terminate() method
# loading StringScanner
require 'strscan'
# declaring StringScanner
c = StringScanner.new("hellogeeks")
puts (c.pos())
# terminate() method
c.terminate()
puts "String Scanner after terminate() : #{c.pos()}\n\n"
输出:
0
String Scanner after terminate() : 10