Ruby program to remove duplicate characters of a string



Ruby program to remove duplicate characters of a string

class RemoveDuplicateCharacter
  def removeDuplicateCharacter
    print "Enter your string: "
    input_string = gets.chomp
    modified_string = ""
    input_string.split("").each do |s|
      modified_string = (modified_string + s) unless  modified_string.split("").include? s 
    end
    print "Modified string: #{modified_string}"
  end
end

p = RemoveDuplicateCharacter.new 
p.removeDuplicateCharacter

Output:


Enter your string:  ummmmmeeeessshh kkkkumarrrr kkkusshwwwaha
Modified string: umesh karw