আজকের টিউটরিয়ালে আরো রুবি কিছু কমান্ড লিখব। রুবি কমান্ডগুলো জানলে রেইলসের বিভিন্ন কোড বোঝা এবং লিখার ক্ষেত্রে সুবিধা হয়ে যাবে।
>> "foo bar baz".split // split এর মাধ্যমে এখানে whitespace split করা হচ্ছে।
=> ["foo", "bar", "baz"]
>> "foo bar\t baz".split
=> ["foo", "bar", "baz"].split
>> "foozzzbarzzzbazzzz".split("zzz")
=> ["foo", "bar", "baz"]
>> a = [42, 8 , 17]
=> [42, 8 , 17]
>> a[0]
=> 42
>> a[1]
=> 8
>> a[2]
=> 17
>> a(-1)
=> 17
>> a
=> (42, 8 , 17)
>> a.first
=> 42
>> a.last
=> 17
>> a.second
=> 8
>> a.length
=> 3
>> a.empty?
=> false
>> a
=> [8, 17, 42]
>> a.sort!
=> [8, 17, 42]
>> a
=> [8,17,42]
>> a.reverse
=> [42,17,8]
>>a
=>[8,17,42]
>> a.reverse!
>> [42,17,8]
>>a
=> [42,17,8]
>> a.shuffle
=> [17,42,8]
>> 1...52.to_a
=> error
>> (1...52).to_a
=> [1,2,3 এখন ৫২ পর্যন্ত প্রিন্ট হবে]
>> a= [76,87,34]
=> [76,87,34]
=> a<<9
=> [76,87,34,9]
>> (1...5) each {|i| puts 2**1}
2
4
8
16
32
=> 1...5
>> a=[]
=> []
>> (1...5) each {|i| a<<2 ** i}
=> 1...5
>> a
=> [2,4,8,16,32]
>> (1...5).map do |i|
>> 2**i
>> end
=> [2,4,8,16,32]
>> 3.times do
>> put "Betelgeuse!"
>>end
betelgeuse !
betelgeuse !
betelgeuse !
=> 3
>> %[a b c]
=> "a b c"
>> %w[a b c]
=> ["a", "b", "c"]
>> %(a b c)
=> "a b c"
>> %("a","b", "c")
=> "\"a\",\"b\",\"c\""
>> "foo".class
=> string
>> :foo.class
=> symbol
>> user= {}
=> {}
>> user.class
=> Hash
>> user["first_name"] = "Mashpy"
=> user["last_name"] = "says"
>> user
=> {"first_name"=>"Mashpy", "last_name" => "Hartl"}
>> user["first_name"]
=> "Michael"
>> user[17] = "Hello"
=> "hello"
>> "hello"
=> user[17]
>> user
=> {"first_name=> "Mashpy", "last_name" => "Says" , 17 => "hello"}
>> "name".length
=> 4
>> s="name"
=> "name"
>> s=="name"
=> true
>> :name.length
=> 4
>> "name".split('')
=> ["n", "a" , "m", "e"]
>> :name.split('')
=> error
>> user [:first_name]
=> Michel
>> flash= {:success=>"it worked", :error=> "it failed"}
=> {:success=>"it worked", :error=> "it failed"}
>> flash.each do |key, value|
?>
puts "Key #{key.inspect} has value #{value.inspect}"
>> end
Key :success has value "It worked!"
Key :error has value "It failed."
আজ এ পর্যন্তই। যদিও টিউটরিয়ালগুলোতে অনেক কিছুর বিস্তারিত লিখি নি। আশা করি পুরো টিউটরিয়াল শেষ হবার পর সব গুলো টিউটরিয়ালে বিস্তারিত লিখে টিউটরিয়ালগুলো আবার ঠিক করব।
>> "foo bar baz".split // split এর মাধ্যমে এখানে whitespace split করা হচ্ছে।
=> ["foo", "bar", "baz"]
>> "foo bar\t baz".split
=> ["foo", "bar", "baz"].split
>> "foozzzbarzzzbazzzz".split("zzz")
=> ["foo", "bar", "baz"]
>> a = [42, 8 , 17]
=> [42, 8 , 17]
>> a[0]
=> 42
>> a[1]
=> 8
>> a[2]
=> 17
>> a(-1)
=> 17
>> a
=> (42, 8 , 17)
>> a.first
=> 42
>> a.last
=> 17
>> a.second
=> 8
>> a.length
=> 3
>> a.empty?
=> false
>> a
=> [8, 17, 42]
>> a.sort!
=> [8, 17, 42]
>> a
=> [8,17,42]
>> a.reverse
=> [42,17,8]
>>a
=>[8,17,42]
>> a.reverse!
>> [42,17,8]
>>a
=> [42,17,8]
>> a.shuffle
=> [17,42,8]
>> 1...52.to_a
=> error
>> (1...52).to_a
=> [1,2,3 এখন ৫২ পর্যন্ত প্রিন্ট হবে]
>> a= [76,87,34]
=> [76,87,34]
=> a<<9
=> [76,87,34,9]
>> (1...5) each {|i| puts 2**1}
2
4
8
16
32
=> 1...5
>> a=[]
=> []
>> (1...5) each {|i| a<<2 ** i}
=> 1...5
>> a
=> [2,4,8,16,32]
>> (1...5).map do |i|
>> 2**i
>> end
=> [2,4,8,16,32]
>> 3.times do
>> put "Betelgeuse!"
>>end
betelgeuse !
betelgeuse !
betelgeuse !
=> 3
>> %[a b c]
=> "a b c"
>> %w[a b c]
=> ["a", "b", "c"]
>> %(a b c)
=> "a b c"
>> %("a","b", "c")
=> "\"a\",\"b\",\"c\""
>> "foo".class
=> string
>> :foo.class
=> symbol
>> user= {}
=> {}
>> user.class
=> Hash
>> user["first_name"] = "Mashpy"
=> user["last_name"] = "says"
>> user
=> {"first_name"=>"Mashpy", "last_name" => "Hartl"}
>> user["first_name"]
=> "Michael"
>> user[17] = "Hello"
=> "hello"
>> "hello"
=> user[17]
>> user
=> {"first_name=> "Mashpy", "last_name" => "Says" , 17 => "hello"}
>> "name".length
=> 4
>> s="name"
=> "name"
>> s=="name"
=> true
>> :name.length
=> 4
>> "name".split('')
=> ["n", "a" , "m", "e"]
>> :name.split('')
=> error
>> user [:first_name]
=> Michel
>> flash= {:success=>"it worked", :error=> "it failed"}
=> {:success=>"it worked", :error=> "it failed"}
>> flash.each do |key, value|
?>
puts "Key #{key.inspect} has value #{value.inspect}"
>> end
Key :success has value "It worked!"
Key :error has value "It failed."
আজ এ পর্যন্তই। যদিও টিউটরিয়ালগুলোতে অনেক কিছুর বিস্তারিত লিখি নি। আশা করি পুরো টিউটরিয়াল শেষ হবার পর সব গুলো টিউটরিয়ালে বিস্তারিত লিখে টিউটরিয়ালগুলো আবার ঠিক করব।
M88 Casino - Sports Betting | Online casino | Odds
ReplyDeleteM88 Casino 메리트카지노 is a top choice of online casino and sports betting. It has vua nhà cái a great online and m88 mobile betting experience. Play casino games,