Skip to content
Related Articles

Related Articles

Improve Article
Ruby | StringScanner rest_size function
  • Last Updated : 10 Dec, 2019

StringScanner#rest_size() : rest_size() is a StringScanner class method which returns the size of the bytes after the string position.

Syntax: StringScanner.rest_size()

Parameter: StringScanner values

Return: the size of the bytes after the string position.

Example #1 :






# Ruby code for StringScanner.rest_size() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("Mon Sep 12 2018 14:39")
  
# rest_size() method
c.pos = 2
puts "String Scanner rest_size form : #{c.rest_size}\n\n"
  
# rest_size() method
c.pos = 7
puts "String Scanner rest_size form : #{c.rest_size}\n\n"

Output :

String Scanner rest_size form : 19

String Scanner rest_size form : 14

Example #2 :




# Ruby code for StringScanner.rest_size() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("hellogeeks")
  
# rest_size() method
c.pos = 2
puts "String Scanner rest_size form : #{c.rest_size}\n\n"
  
# rest_size() method
c.pos = 7
puts "String Scanner rest_size form : #{c.rest_size}\n\n"

Output :

String Scanner rest_size form : 8

String Scanner rest_size form : 3

My Personal Notes arrow_drop_up
Recommended Articles
Page :