forked from ab16ruby/ornekler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path43-metinler.rb
58 lines (46 loc) · 1.32 KB
/
43-metinler.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Metinler
metin = "Merhaba"
metin = 'Merhaba'
puts metin.class # String
metin = %q<Merhaba> # 'Merhaba'
metin = %Q{Merhaba} # "Merhaba"
metin = %(Merhaba) # "Merhaba"
metin = String.new("Merhaba")
puts "Kon'nichi wa!" # Kon'nichi wa!
metin = %*Merhaba "Ruby"* # => "Merhaba \"Ruby\""
puts metin # Merhaba "Ruby"
puts "\tAd\tSoyad\tE-posta"
puts "\tAli\tKara\[email protected]"
puts "\tAyşe\tAk\[email protected]"
puts '\tVeli\tÇak\[email protected]'
uzun_ifade = "Ben uzun bir ifadeyim
bu ruby
dosyasında..." # => "Ben uzun bir ifadeyim\nbu ruby\ndosyasında..."
uzun_ifade = "Ben uzun bir ifadeyim \
bu ruby \
dosyasında..." # => "Ben uzun bir ifadeyim bu ruby dosyasında..."
# Karakter Sabitleri
"\x100" # => "@"
"\40" # => "@"
?a # "a"
?z # "z"
# Metin içerisine kod gömme
$ad = "ali"
$soyad = "kara"
puts "Merhaba, benim adım #{$ad.capitalize} #{$soyad.upcase}"
puts "Metinler içerisine her şeyi gömebiliriz; şuna bak: \
#{def isim
$ad.capitalize + " " + $soyad.upcase
end} benim adım #{isim}"
# Heredoc
metin = <<FALAN
Ben uzun bir metinim,
İstediğin kadar sey ekleyebilirsin
#{$ad} #{$soyad}
FALAN
p metin
metin = <<-FILAN
Ben uzun bir metinim,
İstediğin kadar sey ekleyebilirsin
#{$ad} #{$soyad}
FILAN