Open In App

Ruby | StringScanner empty? function

StringScanner#empty?() : empty?() is a StringScanner class method which checks whether the stringIO is empty.

Syntax: StringScanner.empty?()



Parameter: StringScanner values

Return: true – if the stringIO is empty otherwise return false



Example #1 :




# Ruby code for StringIO.empty?() method
  
# loading StringIO
require 'strscan'
  
# declaring StringIO 
c = StringScanner.new("Fri Dec 12 1975 14:39")
  
# empty?() method
puts "String Scanner empty? form : #{c.empty?()}\n\n"

Output :

String Scanner empty? form : false

Example #2 :




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

Output :

String Scanner empty? form : false
Article Tags :