Update 02.5.md
02.5 devam
This commit is contained in:
22
tr/02.5.md
22
tr/02.5.md
@@ -215,23 +215,23 @@ Bazı sabitleri ve özelleştirilmiş tür/tipleri tanımlarız
|
||||
|
||||
Daha sonra özelleştirilmiş türlerimiz/tiplerimiz için bazı methodlar tanımladık.
|
||||
|
||||
- `Hacim()` uses Kutu as its receiver and returns the volume of Kutu.
|
||||
- `RenkAta(c Color)` changes Box's color.
|
||||
- `EnBuyuklerininRengi()` returns the color which has the biggest volume.
|
||||
- `SiyahaBoya()` sets color for all Box in KutuListesi to SIYAH.
|
||||
- `String()` use Color as its receiver, returns the string format of color name.
|
||||
- `Hacim()` Kutu yu alıcısı olarak kullanır ve onun hacmini döndürür.
|
||||
- `RenkAta(r Renk)` Kutu'nun rengini değiştirir.
|
||||
- `EnBuyuklerininRengi()` en büyük hacimli Kutu'nun rengini döndürür.
|
||||
- `SiyahaBoya()` KutuListesi içindeki tüm Kutu'ların rengini SIYAH yapar.
|
||||
- `String()` Renk'i alıcısı olarak kullanır ve Renk adını string olarak döndürür.
|
||||
|
||||
Is it much clearer when we use words to describe our requirements? We often write our requirements before we start coding.
|
||||
Gereksinimlerimizi tanımlamak için kelimeler kullandığımız zaman daha açıklayıcı değil mi?
|
||||
|
||||
### Use pointer as receiver
|
||||
### İşaretçiyi alıcı olarak kullanmak
|
||||
|
||||
Let's take a look at `RenkAta` method. Its receiver is a pointer of Box. Yes, you can use `*Box` as a receiver. Why do we use a pointer here? Because we want to change Box's color in this method. Thus, if we don't use a pointer, it will only change the value inside a copy of Box.
|
||||
RenkAta metoduna bir göz atalım. Alıcısı Kutunun bir işaretçisidir. Evet, `*Kutu`yu alıcı olarak kullanabilirsiniz. Neden burada bir işaretçi kullanıyoruz? Çünkü bu methodda Kutu'nun rengini değiştirmek istiyoruz. Dolayısıyla, bir işaretçi kullanmazsak, bu yalnızca Kutu'nun kopyasındaki değeri değiştirir.
|
||||
|
||||
If we see that a receiver is the first argument of a method, it's not hard to understand how it works.
|
||||
Bir alıcının bir methodun ilk argümanı olduğunu görürsek, nasıl çalıştığını anlamak zor değildir.
|
||||
|
||||
You might be asking why we aren't using `(*b).Color=c` instead of `b.Color=c` in the `RenkAta()` method. Either one is OK here because Go knows how to interpret the assignment. Do you think Go is more fascinating now?
|
||||
Neden RenkAta() methodunda `k.Renk = r` yerine` (*k).Renk = r` kullanmadığımızı soruyor olabilirsiniz. Her iki kullanımda da sorun yok çünkü Go bu görevi nasıl gerçekleştireceğini bilir. Şimdi Go'nun daha büyüleyici olduğunu düşünmüyor musunuz?
|
||||
|
||||
You may also be asking whether we should use `(&bl[i]).RenkAta(SIYAH)` in `SiyahaBoya` because we pass a pointer to `RenkAta`. Again, either one is OK because Go knows how to interpret it!
|
||||
You may also be asking whether we should use `(&kl[i]).RenkAta(SIYAH)` in `SiyahaBoya` because we pass a pointer to `RenkAta`. Again, either one is OK because Go knows how to interpret it!
|
||||
|
||||
### Inheritance of method
|
||||
|
||||
|
||||
Reference in New Issue
Block a user