📜  红宝石 | StringScanner getch函数

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

红宝石 | StringScanner getch函数

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