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