Skip to content
Related Articles

Related Articles

Improve Article

Ruby | StringScanner pointer= function

  • Last Updated : 10 Dec, 2019

StringScanner#pointer=() : pointer=() is a StringScanner class method which sets the byte position of the scan pointer.

Syntax: StringScanner.pointer=()

Parameter: StringScanner values

Return: sets the byte pointerition of the scan pointer.

Example #1 :






# Ruby code for StringScanner.pointer=() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("Mon Sep 12 2018 14:39")
  
# pointer=() method
c.pointer = 2
  
puts "#{c.rest}\n\n"
  
# pointer=() method
c.pointer = 20
  
puts "#{c.rest}\n\n"

Output :

n Sep 12 2018 14:39

9

Example #2 :




# Ruby code for StringScanner.pointer=() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("hellogeeks")
  
# pointer=() method
c.pointer = 2
  
puts "#{c.rest}\n\n"
  
# pointer=() method
c.pointer = 7
  
puts "#{c.rest}\n\n"

Output :

llogeeks

eks

My Personal Notes arrow_drop_up
Recommended Articles
Page :