This file contains hidden or 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 "Objek ID #{a.object_id}" | |
b = a.succ() | |
puts b | |
puts "Objek ID: #{b.object_id}" |
This file contains hidden or 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 = "Java Ruby Java Ruby" | |
puts a | |
puts "Objek ID: #{a.object_id}" | |
b = a.sub("Java", "Python") | |
puts b | |
puts "Objek ID: #{b.object_id}" |
This file contains hidden or 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 "Objek ID: #{a.object_id}" | |
puts a.length | |
b = a.strip | |
puts b | |
puts "Objek ID: #{b.object_id}" |
This file contains hidden or 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 = "Java|Ruby|PHP|Python" | |
puts a | |
b = a.split("|") | |
puts "Kelas dari variabel b: #{b.class}" | |
puts b | |
This file contains hidden or 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 = "Java Ruby PHP Python HTML" | |
puts a | |
puts "metode slice: #{a.slice(0..3)}" | |
puts "Objek ID: #{a.object_id}" | |
puts "#{a} \n" | |
puts "metode slice! #{a.slice!(0..3)}" | |
puts "Objek ID: #{a.object_id}" |
This file contains hidden or 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}" |
This file contains hidden or 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.rjust(8) | |
puts a.rjust(8, '****') |
This file contains hidden or 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 "metode index()" | |
puts a.index('y') | |
puts "metode rindex()" | |
puts a.rindex('y') |
This file contains hidden or 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 = "Programing Ruby" | |
puts a | |
puts "Objek ID: #{a.object_id}" | |
b = a.reverse | |
puts b | |
puts "Objek ID: #{b.object_id}" |
This file contains hidden or 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 "Objek ID: #{a.object_id}" | |
puts a.replace('Java') | |
puts "Objek ID: #{a.object_id}" | |
b = a.replace('PHP') |