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