Your SlideShare is downloading. ×
0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Code@Six - Ruby 2.0
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Code@Six - Ruby 2.0

293

Published on

Predavanje održano 18.06.2013 na Code@Sixu.

Predavanje održano 18.06.2013 na Code@Sixu.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
293
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. RUBY 2.0Pripovjedač: Nikola Šantić
  • 2. RUBY 2.0MISIJA U MOSKVIPripovjedač: Nikola Šantić
  • 3. Ruby je programski jezik
  • 4. Nijedan jezik nije LOŠosim Visual Basica
  • 5. Nijedan jezik nije LOŠosim Visual Basicai PHPa
  • 6. Nijedan jezik nije LOŠosim Visual Basicai PHPai javascripta
  • 7. Postoje LOŠI jezici
  • 8. Ali Ruby je odličanStvarno
  • 9. 11 razloga zašto je odličan
  • 10. if (sequel == 7)print("yes!")endseries.push("Mission to Moscow")title.reverse().capitalize()1. Zagrade!if sequel == 7print "yes!"endseries.push "Mission to Moscow"title.reverse.capitalize
  • 11. 2. if-ovi bez granicaif character == "Harris"print "MAHONEY!!!"endprint "MAHONEY!!!" if character == "Harris"unless character.russian?play_academy_themeend
  • 12. 3. Sve je objekt"police academy".upcase=> "POLICE ACADEMY"
  • 13. 3. Sve je objekt"police academy".upcase=> "POLICE ACADEMY"mission_to_moscow = Movie.new=> #<Movie:0x00000106f95a40>
  • 14. 3. SVE je objekt"police academy".upcase=> "POLICE ACADEMY"19.years.ago=> Sat, 18 Jun 1994 00:55:38 UTC +00:00mission_to_moscow = Movie.new=> #<Movie:0x00000106f95a40>
  • 15. 4. Najljepši literaliOvo je string bez posebnih znakova n/"Ovo je policijska akademija #{ 6 + 1 }"/police academy [0-9]+/ioscar_reception_date = nilus_gross = 126_247%w(Lassard Jones Tackleberry) == ["Lassard","Jones","Tackleberry"]{de: "Mission in Moskau", it: "Missione a Mosca",hu: "A rendõrakadémia Moszkvában" }
  • 16. 5. Enumeratori(1..20).each do |i|puts iend
  • 17. 5. Enumeratori(1..20).select{|i| i.even?}(1..20).each do |i|puts iend
  • 18. 5. Enumeratori(1..20).select{|i| i.even?}.map{|i| "Razbojnik #{i}"}(1..20).each do |i|puts iend
  • 19. 5. Enumeratori(1..20).select{|i| i.even?}.map{|i| "Razbojnik #{i}"}.each do |i|puts iend(1..20).each do |i|puts iend
  • 20. 6. Zamjena dvije varijablenikad nije bila tako lakax, y = y, x
  • 21. 7. Duck typingif mission_to_moscow.respond_to?(:remake)mission_to_moscow.remakeend
  • 22. 8. DINAMO!"Tackleberry".methods=> [:==, :===, :eql?, :hash, :casecmp, :+, :*,:%, :[], :[]=, ...
  • 23. 8. Dinamično programiranje"Tackleberry".methods=> [:==, :===, :eql?, :hash, :casecmp, :+, :*,:%, :[], :[]=, ...
  • 24. 8. Dinamično programiranje"Tackleberry".methods=> [:==, :===, :eql?, :hash, :casecmp, :+, :*,:%, :[], :[]=, ...class Characterdef speak# bla blaendendjones = Character.newjones.speak
  • 25. 8. Dinamično programiranje"Tackleberry".methods=> [:==, :===, :eql?, :hash, :casecmp, :+, :*,:%, :[], :[]=, ...class Characterdef speak# bla blaendendjones = Character.newjones.speakdef jones.make_noisesputs "beep! boop!"endjones.make_noises
  • 26. 9. Random nasljeđivanjeclass RandomSubclass < [Array, Hash, String, Fixnum, Float].sampleend
  • 27. 10. method_missingclass RussianAcademyProxydef initialize(academy)@academy = academyenddef do_russian_stuff# ...enddef method_missing(method, *args, &block)@academy.send(method, *args, &block)endend
  • 28. 11. Najlakše brisanje diskaIKADrequire fileutilsFileUtils.rm_rf(/)
  • 29. Navodno trebam pričati oRubyju 2.0
  • 30. • Dec 1996 - 1.0• Aug 2003 - 1.8• Dec 2007 - 1.9.0• Aug 2010 - 1.9.2PovijestFEB 24th 2013 - 2.0
  • 31. Nije strašno.Potpuno je kompatibilno s 1.9Koliko je strašno?
  • 32. Što je novo?
  • 33. # encoding: utf-8 više ne treba!proctooooor = "(╯°□°)╯"Default UTF-8
  • 34. Keyword argumentswrap("Blue Oyster Bar")=> "***Blue Oyster Bar***"wrap("Blue Oyster Bar", before: "8=", after: "=>")=> "8=Blue Oyster Bar=>"
  • 35. Keyword argumentsDosad:wrap("Blue Oyster Bar")=> "***Blue Oyster Bar***"wrap("Blue Oyster Bar", before: "8=", after: "=>")=> "8=Blue Oyster Bar=>"def wrap(string, options={})before = options[:before] || ***after = options[:after] || ***"#{before}#{string}#{after}"end
  • 36. Keyword argumentsOdsad:wrap("Blue Oyster Bar")=> "***Blue Oyster Bar***"wrap("Blue Oyster Bar", before: "8=", after: "=>")=> "8=Blue Oyster Bar=>"def wrap(string, before: ***, after: ***)"#{before}#{string}#{after}"end
  • 37. Module#prependclass Characterdef speakputs "Hello"endinclude RussianCultureendrussian = Character.newrussian.drink_votkarussian.speak=> "Hello"Character.ancestors=> [Character, RussianCulture, Object, Kernel, BasicObject]module RussianCulturedef drink_votkaenddef speakputs "привет"endend
  • 38. Module#prependclass Characterdef speakputs "Hello"endprepend RussianCultureendrussian = Character.newrussian.drink_votkarussian.speak=> "привет"Character.ancestors=> [RussianCulture, Character, Object, Kernel, BasicObject]module RussianCulturedef drink_votkaenddef speakputs "привет"endend
  • 39. Module#prependmodule RussianCulturedef speakputs "привет"superputs "прощание"endendrussian.speak=> "привет hello прощание"
  • 40. class Stringdef russian?match(/"p{Cyrillic}+.*?.?"/ui) ? true : falseendend"привет".russian? #=> trueRefinements
  • 41. module RussianQueryrefine String dodef russian?match(/"p{Cyrillic}+.*?.?"/ui) ? true : falseendendend"привет".respond_to?(:russian?) #=> falseusing RussianQuery"привет".russian? #=> trueRefinements
  • 42. (1..Float::INFINITY).map{|i|i.to_s}.select{|s| s =~ /3/}.first(10)Lazy enumeratorX_X
  • 43. (1..Float::INFINITY).lazy.map{|i|i.to_s}.select{|s| s =~ /3/}.first(10)Lazy enumerator
  • 44. • %i{first second third} == [:first, :second, :third]• to_h• array.bsearch{|x| x >= 4}• __dir__• Bolji GCI još
  • 45. RVM: rvm get head && rvm install 2.0.0Kako? Gdje?rbenv: rbenv install 2.0.0-p0
  • 46. Hvala!

×