Skip to content
Related Articles

Related Articles

Improve Article
Ruby | StringScanner terminate function
  • Last Updated : 12 Dec, 2019

StringScanner#terminate() : terminate() is a StringScanner class method which terminates the string pointer.

Syntax: StringScanner.terminate()

Parameter: StringScanner values

Return: terminates the string pointer.

Example #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"

Output :

0
String Scanner after terminate() : 21

Example #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"

Output :

0
String Scanner after terminate() : 10

My Personal Notes arrow_drop_up
Recommended Articles
Page :