Last active
June 13, 2020 14:15
-
-
Save hackjoy/1501059 to your computer and use it in GitHub Desktop.
Ruby [Method]: Insert/Add Characters into String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Transforms ABCDEFGHIJKLMNOPQRSTUVWXY to ABCDE-FGHIJ-KLMNO-PQRS-UVWXY | |
# @number.change_to_licence | |
def change_to_licence | |
h = "-" | |
string = string.insert(5, h) | |
string = string.insert(11, h) | |
string = string.insert(17, h) | |
string = string.insert(23, h) | |
return string | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment