29 Ekim 2008 Çarşamba

rubycan

lan ne uzun zaman olmuş blogcanıma yazmayalı. üşendim baya bi ama sağolsunlar blogger'ı blokladılar ters tepti bi yazıyım dedim. neyse aradan baya bi zaman geçti, ben bu arada ruby kullanmaya başladım. güzel bi scripting dilcanı. perl usulü bir şeyi yapmanın haddinden fazla yolu var. hello world'ün bile. bikaç tane örnek

ben perl'den geldim şöyleyim böyleyim metodu:
print "hello world";

python kullanıyodum ruby de ba benziyo falan dediler metodu:
print "hello world"

python 3000 çıktı uyumlu olmak lazım metodu:
print("hello world")

yok ben c'ciyim eskilerden vazgeçemem metodu:
printf("hello world\n");

c++ güzeldir. oo getirdi diyen oo yu bilmeyen noob metodu:
$stdout << "hello world";

smug lisp weenie metodu:
(print "hello world")

derseniz ki ruby'ye özel bişey yok mu diye:
puts "hello world"

ama tabi bence esas ruby'ye özel olan
send :puts, "hello world"
veya
$stdout.send :<< "hello world"

ayrıca biraz özelleştirmeyle farklı diller de taklit edilebilir.
daha bir c++ mesela:
cout = $stdout
endl = "\n"
cout << "hello world" << endl;

veya c#:
Console = $stdout
class << Console; alias_method :WriteLine, :puts; end
Console.WriteLine("hello world");

java da olur:
module System
def self.out
$stdout
end
end
class << $stdout; alias_method :println, :puts; end
System.out.println("hello world");

fazla mı kastım ne :D

Hiç yorum yok:

Yorum Gönder