5 Şubat 2016 Cuma

Diğer

Variables

Creating a variable reserves a memory location, or a space in memory, for storing values.
To use a variable, it must first be declared by specifying the name and data type.
A variable name, also called an identifier, can contain letters, numbers and the underscore character (_) and must start with a letter or underscore. 
For example, firstName and lastName are good descriptive variable names.

Double vs Float

As the name implies,double has 2x the precision of float. In general a double has 15 decimal digits of precision, while float has 7.

IDE

To create a C# program, you need to install an integrated development environment (IDE) with coding and debugging tools. For example: Visual Studio Community Edition.

Assignment Operators (=) / Postfix & Prefix Operators

The = assignment operator assigns the value on the right side of the operator to the variable on the left side. 
int x = 42;
-
Postfix example:

            int x = 3;
            int y = x++;
            // x is 4, y is 3

The prefix example increments the value of x, and then assigns it to y.
The postfix example assigns the value of x to y, and then increments x.

11 Aralık 2015 Cuma

Ruby'de Array Manipulations

puts"Ornek I"

a = [1, 2, 3]
b = [4, 5]

toplam = a + b
puts toplam  #sonuç: [1, 2, 3, 4, 5]


puts"Ornek II"

c = [1, 2, 3, 4, 5, 6, 7, 8]
d = [2, 4, 5]

res = c - d
puts res #sonuç: [1, 3, 6, 7, 8]

#Birinci array'da bulunan elementlerden, ikinci array'da bulunan elementleri çıkartma işlemi (bildiğimiz çıkarma işlemi şeklinde de düşünülebiliriz)


puts"Ornek III"

e = [1, 2, 3, 4]
f = [3, 4, 5, 6]

puts e & f #sonuç [3, 4]

#Birinci ve ikinci array'larda bulunan aynı elementleri yazdırma işlemi. (a VE b'de bulunan elementler..)


puts"Ornek IV"

g = [1, 3, 5, 7]
h = [2, 4, 6]

puts g | h #sonuç [1, 3, 5, 7, 2, 4, 6]

# g VEYA h'de bulunan elementleri yazdırma işlemi. (yani g'deki elementler +  h'deki elementler)


puts"Ornek V"

newArr = [1, 2, 3, 4]
res = newArr.reverse
puts newArr # [4, 3, 2, 1]

#elementleri ters döndürülmüş sırayla yazdırma.


puts"Ornek VI"

abc = [1, 2, 3]
puts abc.reverse!

#ters döndürülmüş array'ı yeni bir değişkene atmadan direkt olarak "puts" metodu içinde yazdırma

modifying list items with HTML / CSS

<head>
    <style>
        a{text-decoration:none; color:pink;}
        /*a:hover{background-color:white;}*/

        .customStyle:hover{
            background-color:gray;
            transition-duration:0.4s;
            color:red;
        }
       
        /*li span{color:red;}*/
  
        li span{width:600px;  text-indent:1em; display:inline-block;}
        li span:hover{color:black !important;}
       
ul {
    list-style: none;
    padding:3;
    margin:10;
}

li {
    padding-left: 5em;
    text-indent: -.em;
}

li:before {
    content: "• ";
    color: red; /* or whatever color you prefer */
}

li:hover:before{
    content:" ○";
    color:white ;
}

li:after{
    content:" •";
    color:green;
}

li:hover:after{
    content:" ○";
    color:white;
}
    </style>
</head>

<body style="background-color:#272822">
<ul>
    <a href=""><li class="customStyle"><span>Anasayfa</span></li></a>
    <a href=""><li class="customStyle"><span>Kitaplar</span></li></a>
    <a href=""><li class="customStyle"><span>Yazarlar</span></li></a>
</ul>
</body>

8 Aralık 2015 Salı

Ruby'de .to_i ve unless kullanımı

a = gets.to_i   #kullanıcının girdiği veriyi integer'a dönüştürdük.

puts "16 dan buyuk" if a > 16

puts "25 ten kucuk" unless a < 25

#
#
#

#else keyword'ü ile örnek yapalım:

deg = gets.to_i

unless deg == 12
puts "12 ye esit degil"
else
    puts "12 ye esit"
end


Ruby'de if anahtar kelimesi kullanımı

sayi = 15;

if sayi > 11
    puts "Sayi 11' den buyuk"
    if sayi < 44
        puts "Sayi 44'den kucuk"
    end
end
   
#sonuç:

  #Sayi 11' den buyuk
  #Sayi 44'den kucuk

Ruby'de .eql metodu

x = 5;

y = 6;

puts "---1---";

puts x.eql?(y);

# .eql? metodu true veya false sonuç dönderir. Şu durumda true dönderecektir:

# iki değişkenin Tipi de birbirine eşit olmalı ve iki değişkenin değeri birbirine eşit olmalı.

puts "---2---";

puts x == 5.0;
# veya:
puts 5 == 5.0;
# şeklinde yazılmış önermeler "true" dönderecektir. (Her iki tip birbirinden farklı olsa da (5 = integer ve 5.0 = boolean) dönen sonuç true olacaktır. Çünkü değerleri birbirine eşittir (5)

# Fakat yukarıda da belirtildiği gibi .eql metodunda hem değerler hem de tipler birbirine eşit olmalıdır.

puts "---3---";

puts x.eql?(5.0);
# veya
puts 5.eql?(5.0);

# önermeleri False dönecektir.


Ruby'de String Interpolation

numberOne, numberTwo = 1,2;

puts "Girilen sayilarin toplami #{numberOne + numberTwo} 'tur"

#sonuç: Girilen sayilarin toplami 3 'tur

#String Interpolation; çift tırnak içerisinde Ruby ifadelerinin kullanılması yöntemidir. Örneğin değişkenleri tırnak içerisinde kullanabilir, yazdırabiliriz. 
Yukarıda “puts” metodu içerisine numberOne ve numberTwo değişkenlerinin toplamını, istediğimiz bir text ile beraber yazdırdık.

Ruby'de Parallel Assignment

#Parallel Assignment in RUby

#Ruby'de Parallel Assignment kullanılarak tek bir satırda birçok değişken oluşturulabilir veya önceden oluşturulmuş değişkenlerin değerleri değiştirilebilir.

degisken1, degisken2, degisken3 = 1,2,3;

puts degisken1;
puts degisken2;
puts degisken3;
puts "";

degisken1, degisken2, degisken3 = 4,5,6;

puts degisken1;
puts degisken2;
puts degisken3;
puts "";

#Paralel Assignment kullanılarak iki değişkenin değerlerini birbirleri arasında değiş tokuş ettirebiliriz.

a = "ali";
v = "veli";

puts a;
puts v;
puts "";

a,v = v,a;

puts "'a' nin su anki degeri: #{a}";
puts "'b' nin su anki degeri: #{v}";