Last active
April 22, 2020 14:07
-
-
Save wicky-andrian/26dcdfef8bce7668400a0a4b7f924abf to your computer and use it in GitHub Desktop.
Contoh metode string part 5
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
a = " Ruby " | |
puts a | |
puts "Jumlah karakter: #{a.length}" | |
puts "Objek ID: #{a.object_id}" | |
b = a.rstrip | |
puts b | |
puts "Jumlah karakter: #{b.length}" | |
puts "Objek id: #{b.object_id}" | |
c = a.rstrip! | |
puts c | |
puts "Jumlah karakter: #{c.length}" | |
puts "Objek ID: #{c.object_id}" | |
# output di terminal | |
Ruby | |
Jumlah karakter: 9 | |
Objek ID: 60 | |
Ruby | |
Jumlah karakter: 6 | |
Objek id: 80 | |
Ruby | |
Jumlah karakter: 6 | |
Objek ID: 60 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment