5a – Subtracting Integers withMathLine 5a - Subtracting Integers.
Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be...
Transcript of Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be...
![Page 1: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/1.jpg)
Themenabend Ruby
Sven & Astro
March 28, 2006
Sven & Astro () Themenabend Ruby March 28, 2006 1 / 90
![Page 2: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/2.jpg)
Ruby has simple syntax, partially inspired by Eiffel and Ada.
Ruby has exception handling features, like Java or Python, to make it easy to handle errors.
Ruby’s operators are syntax sugar for the methods. You can redefine them easily.
Ruby is a complete, full, pure object oriented language: OOL. This means all data in Ruby is an object, in the sense ofSmalltalk: no exceptions. Example: In Ruby, the number 1 is an instance of class Fixnum.
Ruby’s OO is carefully designed to be both complete and open for improvements. Example: Ruby has the ability to addmethods to a class, or even to an instance during runtime. So, if needed, an instance of one class *can* behavedifferently from other instances of the same class.
Ruby features single inheritance only, *on purpose*. But Ruby knows the concept of modules (called Categories inObjective-C). Modules are collections of methods. Every class can import a module and so gets all its methods for free.Some of us think that this is a much clearer way than multiple inheritance, which is complex, and not used very oftencompared with single inheritance (don’t count C++ here, as it has often no other choice due to strong type checking!).
Ruby features true closures. Not just unnamed function, but with present variable bindings.
Ruby features blocks in its syntax (code surrounded by ’{’ ... ’}’ or ’do’ ... ’end’). These blocks can be passed tomethods, or converted into closures.
Ruby features a true mark-and-sweep garbage collector. It works with all Ruby objects. You don’t have to care aboutmaintaining reference counts in extension libraries. This is better for your health. ;-)
Writing C extensions in Ruby is easier than in Perl or Python, due partly to the garbage collector, and partly to the fineextension API. SWIG interface is also available.
Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers(instances of class Fixnum) and large integers (Bignum), but you need not worry over which one is used currently. If avalue is small enough, an integer is a Fixnum, otherwise it is a Bignum. Conversion occurs automatically.
Ruby needs no variable declarations. It uses simple naming conventions to denote the scope of variables. Examples:simple ’var’ = local variable, ’@var’ = instance variable, ’$var’ = global variable. So it is also not necessary to use atiresome ’self.’ prepended to every instance member.
Ruby can load extension libraries dynamically if an OS allows.
Ruby features OS independent threading. Thus, for all platforms on which Ruby runs, you also have multithreading,regardless of if the OS supports it or not, even on MS-DOS! ;-)
Ruby is highly portable: it is developed mostly on Linux, but works on many types of UNIX, DOS, Windows95/98/Me/NT/2000/XP, MacOS, BeOS, OS/2, etc.
Sven & Astro () Themenabend Ruby March 28, 2006 2 / 90
![Page 3: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/3.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 3 / 90
![Page 4: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/4.jpg)
Herkunft
”Perl“: Perle
”Ruby“: Rubin
”Ruby ist eine objektorientierte, interpretierte Programmiersprache.
Sie hat ihre Wurzeln in Perl, Smalltalk, Python, LISP, Bash undCLU.“ Wikipedia1
1http://de.wikipedia.org/wiki/Ruby %28Programmiersprache%29Sven & Astro () Themenabend Ruby March 28, 2006 4 / 90
![Page 5: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/5.jpg)
Entwicklung
Februar 1993: Yukihiro”Matz“ Matsumoto beginnt Entwicklung
Dezember 1995: Erste Veroffentlichung
$ ruby -vruby 1.8.4 (2005-12-24) [i386-freebsd6]
Ruby 1.9: Rite, Ruby2
Sven & Astro () Themenabend Ruby March 28, 2006 5 / 90
![Page 6: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/6.jpg)
Entwicklung
Februar 1993: Yukihiro”Matz“ Matsumoto beginnt Entwicklung
Dezember 1995: Erste Veroffentlichung
$ ruby -vruby 1.8.4 (2005-12-24) [i386-freebsd6]
Ruby 1.9: Rite, Ruby2
Sven & Astro () Themenabend Ruby March 28, 2006 5 / 90
![Page 7: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/7.jpg)
Entwicklung
Februar 1993: Yukihiro”Matz“ Matsumoto beginnt Entwicklung
Dezember 1995: Erste Veroffentlichung
$ ruby -vruby 1.8.4 (2005-12-24) [i386-freebsd6]
Ruby 1.9: Rite, Ruby2
Sven & Astro () Themenabend Ruby March 28, 2006 5 / 90
![Page 8: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/8.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 6 / 90
![Page 9: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/9.jpg)
Hilfe?
www.ruby-lang.org
”Programming Ruby“
http://www.rubycentral.com/book
Sven & Astro () Themenabend Ruby March 28, 2006 7 / 90
![Page 10: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/10.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 8 / 90
![Page 11: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/11.jpg)
irb – Interactive Ruby
Um schnell etwas auszuprobieren
Toller bc(1)-Ersatz
Sven & Astro () Themenabend Ruby March 28, 2006 9 / 90
![Page 12: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/12.jpg)
irb – Interactive Ruby
Um schnell etwas auszuprobieren
Toller bc(1)-Ersatz
Sven & Astro () Themenabend Ruby March 28, 2006 9 / 90
![Page 13: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/13.jpg)
ri
Integrierte Dokumentation
Lasst sich mit Rdoc erstellen
Sven & Astro () Themenabend Ruby March 28, 2006 10 / 90
![Page 14: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/14.jpg)
ri
Integrierte Dokumentation
Lasst sich mit Rdoc erstellen
Sven & Astro () Themenabend Ruby March 28, 2006 10 / 90
![Page 15: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/15.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 11 / 90
![Page 16: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/16.jpg)
Variablen
Lokale Variablen: v = 23
Instanzvariablen: @v = 23
Klassenvariablen: @@v = 23
Globale Variablen: $v = 23Zum Beispiel: $stdin, $stdout, $stderr
Sven & Astro () Themenabend Ruby March 28, 2006 12 / 90
![Page 17: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/17.jpg)
Variablen
Lokale Variablen: v = 23
Instanzvariablen: @v = 23
Klassenvariablen: @@v = 23
Globale Variablen: $v = 23Zum Beispiel: $stdin, $stdout, $stderr
Sven & Astro () Themenabend Ruby March 28, 2006 12 / 90
![Page 18: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/18.jpg)
Variablen
Lokale Variablen: v = 23
Instanzvariablen: @v = 23
Klassenvariablen: @@v = 23
Globale Variablen: $v = 23Zum Beispiel: $stdin, $stdout, $stderr
Sven & Astro () Themenabend Ruby March 28, 2006 12 / 90
![Page 19: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/19.jpg)
Variablen
Lokale Variablen: v = 23
Instanzvariablen: @v = 23
Klassenvariablen: @@v = 23
Globale Variablen: $v = 23Zum Beispiel: $stdin, $stdout, $stderr
Sven & Astro () Themenabend Ruby March 28, 2006 12 / 90
![Page 20: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/20.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 13 / 90
![Page 21: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/21.jpg)
Alles ist ein Objekt
mein string = "Hallo"=> "Hallo"
mein string.reverse=> "ollaH"
"Hallo".reverse=> "ollaH"
mein string => "Hallo"
mein string.reverse! => "ollaH"
mein string => "ollaH"
Sven & Astro () Themenabend Ruby March 28, 2006 14 / 90
![Page 22: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/22.jpg)
Alles ist ein Objekt
mein string = "Hallo"=> "Hallo"
mein string.reverse=> "ollaH"
"Hallo".reverse=> "ollaH"
mein string => "Hallo"
mein string.reverse! => "ollaH"
mein string => "ollaH"
Sven & Astro () Themenabend Ruby March 28, 2006 14 / 90
![Page 23: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/23.jpg)
Alles ist ein Objekt
mein string = "Hallo"=> "Hallo"
mein string.reverse=> "ollaH"
"Hallo".reverse=> "ollaH"
mein string => "Hallo"
mein string.reverse! => "ollaH"
mein string => "ollaH"
Sven & Astro () Themenabend Ruby March 28, 2006 14 / 90
![Page 24: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/24.jpg)
Alles ist ein Objekt
mein string = "Hallo"=> "Hallo"
mein string.reverse=> "ollaH"
"Hallo".reverse=> "ollaH"
mein string => "Hallo"
mein string.reverse! => "ollaH"
mein string => "ollaH"
Sven & Astro () Themenabend Ruby March 28, 2006 14 / 90
![Page 25: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/25.jpg)
Alles ist ein Objekt
mein string = "Hallo"=> "Hallo"
mein string.reverse=> "ollaH"
"Hallo".reverse=> "ollaH"
mein string => "Hallo"
mein string.reverse! => "ollaH"
mein string => "ollaH"
Sven & Astro () Themenabend Ruby March 28, 2006 14 / 90
![Page 26: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/26.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 15 / 90
![Page 27: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/27.jpg)
Konventionen
Module, Klassen, Konstanten, Klassenmethoden, Modulmethoden:Net::HTTP, Thread::stop ⇔ Thread.stop
Instanzmethoden:String#upcase, Array#collect
Modul- und Klassennamen in CamelCase
Sven & Astro () Themenabend Ruby March 28, 2006 16 / 90
![Page 28: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/28.jpg)
Konventionen
Module, Klassen, Konstanten, Klassenmethoden, Modulmethoden:Net::HTTP, Thread::stop ⇔ Thread.stop
Instanzmethoden:String#upcase, Array#collect
Modul- und Klassennamen in CamelCase
Sven & Astro () Themenabend Ruby March 28, 2006 16 / 90
![Page 29: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/29.jpg)
Konventionen
Module, Klassen, Konstanten, Klassenmethoden, Modulmethoden:Net::HTTP, Thread::stop ⇔ Thread.stop
Instanzmethoden:String#upcase, Array#collect
Modul- und Klassennamen in CamelCase
Sven & Astro () Themenabend Ruby March 28, 2006 16 / 90
![Page 30: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/30.jpg)
Konventionen (Methodennamen)
Methodennamen kleingeschrieben: Array#each with index
Funktion mit booleschem Ergebnis:heuhaufen.include? nadelIO#closed?
Gefahrliche Funktionen: String#reverse!, Array#collect!
Sven & Astro () Themenabend Ruby March 28, 2006 17 / 90
![Page 31: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/31.jpg)
Konventionen (Methodennamen)
Methodennamen kleingeschrieben: Array#each with index
Funktion mit booleschem Ergebnis:heuhaufen.include? nadelIO#closed?
Gefahrliche Funktionen: String#reverse!, Array#collect!
Sven & Astro () Themenabend Ruby March 28, 2006 17 / 90
![Page 32: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/32.jpg)
Konventionen (Methodennamen)
Methodennamen kleingeschrieben: Array#each with index
Funktion mit booleschem Ergebnis:heuhaufen.include? nadelIO#closed?
Gefahrliche Funktionen: String#reverse!, Array#collect!
Sven & Astro () Themenabend Ruby March 28, 2006 17 / 90
![Page 33: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/33.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 18 / 90
![Page 34: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/34.jpg)
p
zeilenverzeichnis = "Zeile 1\nZeile 2"
p zeilenverzeichnis"Zeile 1\nZeile 2"
puts zeilenverzeichnis.inspect"Zeile 1\nZeile 2"
p zeilenverzeichnis.inspect.classString
p zeilenverzeichnis.inspect"\"Zeile 1\\nZeile 2\""
Sven & Astro () Themenabend Ruby March 28, 2006 19 / 90
![Page 35: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/35.jpg)
p
zeilenverzeichnis = "Zeile 1\nZeile 2"
p zeilenverzeichnis"Zeile 1\nZeile 2"
puts zeilenverzeichnis.inspect"Zeile 1\nZeile 2"
p zeilenverzeichnis.inspect.classString
p zeilenverzeichnis.inspect"\"Zeile 1\\nZeile 2\""
Sven & Astro () Themenabend Ruby March 28, 2006 19 / 90
![Page 36: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/36.jpg)
p
zeilenverzeichnis = "Zeile 1\nZeile 2"
p zeilenverzeichnis"Zeile 1\nZeile 2"
puts zeilenverzeichnis.inspect"Zeile 1\nZeile 2"
p zeilenverzeichnis.inspect.classString
p zeilenverzeichnis.inspect"\"Zeile 1\\nZeile 2\""
Sven & Astro () Themenabend Ruby March 28, 2006 19 / 90
![Page 37: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/37.jpg)
p
zeilenverzeichnis = "Zeile 1\nZeile 2"
p zeilenverzeichnis"Zeile 1\nZeile 2"
puts zeilenverzeichnis.inspect"Zeile 1\nZeile 2"
p zeilenverzeichnis.inspect.classString
p zeilenverzeichnis.inspect"\"Zeile 1\\nZeile 2\""
Sven & Astro () Themenabend Ruby March 28, 2006 19 / 90
![Page 38: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/38.jpg)
p
zeilenverzeichnis = "Zeile 1\nZeile 2"
p zeilenverzeichnis"Zeile 1\nZeile 2"
puts zeilenverzeichnis.inspect"Zeile 1\nZeile 2"
p zeilenverzeichnis.inspect.classString
p zeilenverzeichnis.inspect"\"Zeile 1\\nZeile 2\""
Sven & Astro () Themenabend Ruby March 28, 2006 19 / 90
![Page 39: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/39.jpg)
p
a = [11, ’X’]
p a[11, "X"]
p meine instanz#<MeineKlasse:0x82690b4 @variable2="discordia",@variable1="eris">
Sven & Astro () Themenabend Ruby March 28, 2006 20 / 90
![Page 40: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/40.jpg)
p
a = [11, ’X’]
p a[11, "X"]
p meine instanz#<MeineKlasse:0x82690b4 @variable2="discordia",@variable1="eris">
Sven & Astro () Themenabend Ruby March 28, 2006 20 / 90
![Page 41: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/41.jpg)
p
a = [11, ’X’]
p a[11, "X"]
p meine instanz#<MeineKlasse:0x82690b4 @variable2="discordia",@variable1="eris">
Sven & Astro () Themenabend Ruby March 28, 2006 20 / 90
![Page 42: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/42.jpg)
inspect selbst definieren
class << meine instanzdef inspect"<#self.class(#@variable1,#@variable2)>"
endend
p meine instanz<MeineKlasse(eris,discordia)>
Sven & Astro () Themenabend Ruby March 28, 2006 21 / 90
![Page 43: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/43.jpg)
inspect selbst definieren
class << meine instanzdef inspect"<#self.class(#@variable1,#@variable2)>"
endend
p meine instanz<MeineKlasse(eris,discordia)>
Sven & Astro () Themenabend Ruby March 28, 2006 21 / 90
![Page 44: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/44.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 22 / 90
![Page 45: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/45.jpg)
Primitive Datentypen
nil.class=> NilClass
false.class=> FalseClass
true.class=> TrueClass
Sven & Astro () Themenabend Ruby March 28, 2006 23 / 90
![Page 46: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/46.jpg)
Primitive Datentypen
nil.class=> NilClass
false.class=> FalseClass
true.class=> TrueClass
Sven & Astro () Themenabend Ruby March 28, 2006 23 / 90
![Page 47: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/47.jpg)
Primitive Datentypen
nil.class=> NilClass
false.class=> FalseClass
true.class=> TrueClass
Sven & Astro () Themenabend Ruby March 28, 2006 23 / 90
![Page 48: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/48.jpg)
Strings
’Hier mussen nur \\ und \’ escaped werden.’
"Hier konnen wir auch anderes escapen\n""und Code einbetten: #{ENV[’PATH’]}"
Sven & Astro () Themenabend Ruby March 28, 2006 24 / 90
![Page 49: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/49.jpg)
Strings
’Hier mussen nur \\ und \’ escaped werden.’
"Hier konnen wir auch anderes escapen\n"
"und Code einbetten: #{ENV[’PATH’]}"
Sven & Astro () Themenabend Ruby March 28, 2006 24 / 90
![Page 50: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/50.jpg)
Strings
’Hier mussen nur \\ und \’ escaped werden.’
"Hier konnen wir auch anderes escapen\n""und Code einbetten: #{ENV[’PATH’]}"
Sven & Astro () Themenabend Ruby March 28, 2006 24 / 90
![Page 51: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/51.jpg)
Nummern
23.class=> Fixnum
23.5.class=> Float
(5**100).to s.size=> 32(5**100).class=> Bignum
Sven & Astro () Themenabend Ruby March 28, 2006 25 / 90
![Page 52: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/52.jpg)
Nummern
23.class=> Fixnum
23.5.class=> Float
(5**100).to s.size=> 32(5**100).class=> Bignum
Sven & Astro () Themenabend Ruby March 28, 2006 25 / 90
![Page 53: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/53.jpg)
Nummern
23.class=> Fixnum
23.5.class=> Float
(5**100).to s.size=> 32(5**100).class=> Bignum
Sven & Astro () Themenabend Ruby March 28, 2006 25 / 90
![Page 54: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/54.jpg)
Arrays
mein array = [5, 23, ’R00by’]
mein array=> [5, 23, ’R00by’]
mein array[1]=> 23
mein array.reverse=> [’R00by’, 23, 5]
Sven & Astro () Themenabend Ruby March 28, 2006 26 / 90
![Page 55: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/55.jpg)
Arrays
mein array = [5, 23, ’R00by’]
mein array=> [5, 23, ’R00by’]
mein array[1]=> 23
mein array.reverse=> [’R00by’, 23, 5]
Sven & Astro () Themenabend Ruby March 28, 2006 26 / 90
![Page 56: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/56.jpg)
Arrays
mein array = [5, 23, ’R00by’]
mein array=> [5, 23, ’R00by’]
mein array[1]=> 23
mein array.reverse=> [’R00by’, 23, 5]
Sven & Astro () Themenabend Ruby March 28, 2006 26 / 90
![Page 57: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/57.jpg)
Arrays
mein array.each do |element|puts element
end
mein array.each { |element|puts element
}523R00bymein array.each with index { |element,index|puts "#{index}: #{element}"
}0: 51: 232: R00by=> [5, 23, "R00by"]
Sven & Astro () Themenabend Ruby March 28, 2006 27 / 90
![Page 58: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/58.jpg)
Arrays
mein array.each do |element|puts element
endmein array.each { |element|puts element
}
523R00bymein array.each with index { |element,index|puts "#{index}: #{element}"
}0: 51: 232: R00by=> [5, 23, "R00by"]
Sven & Astro () Themenabend Ruby March 28, 2006 27 / 90
![Page 59: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/59.jpg)
Arrays
mein array.each do |element|puts element
endmein array.each { |element|puts element
}523R00by
mein array.each with index { |element,index|puts "#{index}: #{element}"
}0: 51: 232: R00by=> [5, 23, "R00by"]
Sven & Astro () Themenabend Ruby March 28, 2006 27 / 90
![Page 60: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/60.jpg)
Arrays
mein array.each do |element|puts element
endmein array.each { |element|puts element
}523R00bymein array.each with index { |element,index|puts "#{index}: #{element}"
}
0: 51: 232: R00by=> [5, 23, "R00by"]
Sven & Astro () Themenabend Ruby March 28, 2006 27 / 90
![Page 61: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/61.jpg)
Arrays
mein array.each do |element|puts element
endmein array.each { |element|puts element
}523R00bymein array.each with index { |element,index|puts "#{index}: #{element}"
}0: 51: 232: R00by=> [5, 23, "R00by"]
Sven & Astro () Themenabend Ruby March 28, 2006 27 / 90
![Page 62: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/62.jpg)
Arrays und Variablenzuweisung
a = ’Hund’, ’Katze’=> ["Hund", "Katze"]
hund, katze = a=> ["Hund", "Katze"]
hund=> "Hund"
katze=> "Katze"
hund, katze = ’Hund’, ’Katze’=> ["Hund", "Katze"]
hund=> "Hund"
katze=> "Katze"
Inhalt tauschen: a, b = b, a
Sven & Astro () Themenabend Ruby March 28, 2006 28 / 90
![Page 63: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/63.jpg)
Arrays und Variablenzuweisung
a = ’Hund’, ’Katze’=> ["Hund", "Katze"]
hund, katze = a=> ["Hund", "Katze"]
hund=> "Hund"
katze=> "Katze"
hund, katze = ’Hund’, ’Katze’=> ["Hund", "Katze"]
hund=> "Hund"
katze=> "Katze"
Inhalt tauschen: a, b = b, a
Sven & Astro () Themenabend Ruby March 28, 2006 28 / 90
![Page 64: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/64.jpg)
Arrays und Variablenzuweisung
a = ’Hund’, ’Katze’=> ["Hund", "Katze"]
hund, katze = a=> ["Hund", "Katze"]
hund=> "Hund"
katze=> "Katze"
hund, katze = ’Hund’, ’Katze’=> ["Hund", "Katze"]
hund=> "Hund"
katze=> "Katze"
Inhalt tauschen: a, b = b, a
Sven & Astro () Themenabend Ruby March 28, 2006 28 / 90
![Page 65: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/65.jpg)
Arrays und Variablenzuweisung
a = ’Hund’, ’Katze’=> ["Hund", "Katze"]
hund, katze = a=> ["Hund", "Katze"]
hund=> "Hund"
katze=> "Katze"
hund, katze = ’Hund’, ’Katze’=> ["Hund", "Katze"]
hund=> "Hund"
katze=> "Katze"
Inhalt tauschen: a, b = b, a
Sven & Astro () Themenabend Ruby March 28, 2006 28 / 90
![Page 66: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/66.jpg)
Hashes
mein hash = {’Mate’ => 1.0, ’Datenschleuder’ => 2.5}mein hash=> {’Datenschleuder’ => 2.5, ’Mate’ => 1.0}
mein hash[’Mate’]=> 1.0
mein hash.keys=> [’Datenschleuder’, ’Mate’]
Sven & Astro () Themenabend Ruby March 28, 2006 29 / 90
![Page 67: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/67.jpg)
Hashes
mein hash = {’Mate’ => 1.0, ’Datenschleuder’ => 2.5}mein hash=> {’Datenschleuder’ => 2.5, ’Mate’ => 1.0}mein hash[’Mate’]=> 1.0
mein hash.keys=> [’Datenschleuder’, ’Mate’]
Sven & Astro () Themenabend Ruby March 28, 2006 29 / 90
![Page 68: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/68.jpg)
Hashes
mein hash = {’Mate’ => 1.0, ’Datenschleuder’ => 2.5}mein hash=> {’Datenschleuder’ => 2.5, ’Mate’ => 1.0}mein hash[’Mate’]=> 1.0
mein hash.keys=> [’Datenschleuder’, ’Mate’]
Sven & Astro () Themenabend Ruby March 28, 2006 29 / 90
![Page 69: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/69.jpg)
Hashes (Iteratoren)
mein hash.each do |artikel,preis|puts "#{artikel} kostet #{preis} FRZ"
end
Datenschleuder kostet 2.5 FRZMate kostet 1.0 FRZ=> {"Datenschleuder"=>2.5, "Mate"=>1.0}puts mein hash.collect { |artikel,preis| "#{artikel}:#{preis}" }.join("\n")Datenschleuder: 2.5Mate: 1.0=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 30 / 90
![Page 70: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/70.jpg)
Hashes (Iteratoren)
mein hash.each do |artikel,preis|puts "#{artikel} kostet #{preis} FRZ"
end
Datenschleuder kostet 2.5 FRZMate kostet 1.0 FRZ=> {"Datenschleuder"=>2.5, "Mate"=>1.0}
puts mein hash.collect { |artikel,preis| "#{artikel}:#{preis}" }.join("\n")Datenschleuder: 2.5Mate: 1.0=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 30 / 90
![Page 71: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/71.jpg)
Hashes (Iteratoren)
mein hash.each do |artikel,preis|puts "#{artikel} kostet #{preis} FRZ"
end
Datenschleuder kostet 2.5 FRZMate kostet 1.0 FRZ=> {"Datenschleuder"=>2.5, "Mate"=>1.0}puts mein hash.collect { |artikel,preis| "#{artikel}:#{preis}" }.join("\n")
Datenschleuder: 2.5Mate: 1.0=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 30 / 90
![Page 72: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/72.jpg)
Hashes (Iteratoren)
mein hash.each do |artikel,preis|puts "#{artikel} kostet #{preis} FRZ"
end
Datenschleuder kostet 2.5 FRZMate kostet 1.0 FRZ=> {"Datenschleuder"=>2.5, "Mate"=>1.0}puts mein hash.collect { |artikel,preis| "#{artikel}:#{preis}" }.join("\n")Datenschleuder: 2.5Mate: 1.0=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 30 / 90
![Page 73: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/73.jpg)
Ranges
mein range = 5..23=> 5..23
mein range.include? 8=> true
mein range.include? 1=> false
case coolnesswhen 0..20 then puts "Perl"when 21..60 then puts "Python"when 61..100 then puts "Ruby"
end
Sven & Astro () Themenabend Ruby March 28, 2006 31 / 90
![Page 74: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/74.jpg)
Ranges
mein range = 5..23=> 5..23
mein range.include? 8=> true
mein range.include? 1=> false
case coolnesswhen 0..20 then puts "Perl"when 21..60 then puts "Python"when 61..100 then puts "Ruby"
end
Sven & Astro () Themenabend Ruby March 28, 2006 31 / 90
![Page 75: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/75.jpg)
Ranges
mein range = 5..23=> 5..23
mein range.include? 8=> true
mein range.include? 1=> false
case coolnesswhen 0..20 then puts "Perl"when 21..60 then puts "Python"when 61..100 then puts "Ruby"
end
Sven & Astro () Themenabend Ruby March 28, 2006 31 / 90
![Page 76: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/76.jpg)
Regexp
puts "Mentions Ruby" if text =~ /Ruby/
if ’Ruby is cool’ =~ /(.+) is (.+)/puts "#{$1} ist #{$2}"
end
Ruby ist cool
if m = r.match(’Ruby is cool’)p m.captures
end
["Ruby", "cool"]
’Ruby is cool. Sky is blue.’.scan(/ *(.+?) is(.+?)\./)=> [["Ruby", "cool"], ["Sky", "blue"]]
Sven & Astro () Themenabend Ruby March 28, 2006 32 / 90
![Page 77: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/77.jpg)
Regexp
puts "Mentions Ruby" if text =~ /Ruby/
if ’Ruby is cool’ =~ /(.+) is (.+)/puts "#{$1} ist #{$2}"
end
Ruby ist cool
if m = r.match(’Ruby is cool’)p m.captures
end
["Ruby", "cool"]
’Ruby is cool. Sky is blue.’.scan(/ *(.+?) is(.+?)\./)=> [["Ruby", "cool"], ["Sky", "blue"]]
Sven & Astro () Themenabend Ruby March 28, 2006 32 / 90
![Page 78: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/78.jpg)
Regexp
puts "Mentions Ruby" if text =~ /Ruby/
if ’Ruby is cool’ =~ /(.+) is (.+)/puts "#{$1} ist #{$2}"
end
Ruby ist cool
if m = r.match(’Ruby is cool’)p m.captures
end
["Ruby", "cool"]
’Ruby is cool. Sky is blue.’.scan(/ *(.+?) is(.+?)\./)=> [["Ruby", "cool"], ["Sky", "blue"]]
Sven & Astro () Themenabend Ruby March 28, 2006 32 / 90
![Page 79: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/79.jpg)
Regexp
puts "Mentions Ruby" if text =~ /Ruby/
if ’Ruby is cool’ =~ /(.+) is (.+)/puts "#{$1} ist #{$2}"
end
Ruby ist cool
if m = r.match(’Ruby is cool’)p m.captures
end
["Ruby", "cool"]
’Ruby is cool. Sky is blue.’.scan(/ *(.+?) is(.+?)\./)=> [["Ruby", "cool"], ["Sky", "blue"]]
Sven & Astro () Themenabend Ruby March 28, 2006 32 / 90
![Page 80: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/80.jpg)
Symbols
Symbole reprasentieren Namen oder Strings
a = "Ruby"b = "Ruby"a.object id=> 403028500
b.object id=> 403010020
c = :Rubyd = :"Ruby"c.object id=> 4121870
d.object id=> 4121870
Sven & Astro () Themenabend Ruby March 28, 2006 33 / 90
![Page 81: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/81.jpg)
Symbols
Symbole reprasentieren Namen oder Strings
a = "Ruby"b = "Ruby"a.object id=> 403028500
b.object id=> 403010020
c = :Rubyd = :"Ruby"c.object id=> 4121870
d.object id=> 4121870
Sven & Astro () Themenabend Ruby March 28, 2006 33 / 90
![Page 82: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/82.jpg)
Symbols
Symbole reprasentieren Namen oder Strings
a = "Ruby"b = "Ruby"a.object id=> 403028500
b.object id=> 403010020
c = :Rubyd = :"Ruby"c.object id=> 4121870
d.object id=> 4121870
Sven & Astro () Themenabend Ruby March 28, 2006 33 / 90
![Page 83: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/83.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 34 / 90
![Page 84: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/84.jpg)
if
if Ruby::is cool?applause!
end
if hacker.is hacking?hacker.continue hacking
elsehacker.start hacking
end
unless hacker.is hacking?hacker.start hacking
elsehacker.continue hacking
end
Alternativ: (condition ? then clause : else clause)
Sven & Astro () Themenabend Ruby March 28, 2006 35 / 90
![Page 85: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/85.jpg)
if
if Ruby::is cool?applause!
end
if hacker.is hacking?hacker.continue hacking
elsehacker.start hacking
end
unless hacker.is hacking?hacker.start hacking
elsehacker.continue hacking
end
Alternativ: (condition ? then clause : else clause)
Sven & Astro () Themenabend Ruby March 28, 2006 35 / 90
![Page 86: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/86.jpg)
if
if Ruby::is cool?applause!
end
if hacker.is hacking?hacker.continue hacking
elsehacker.start hacking
end
unless hacker.is hacking?hacker.start hacking
elsehacker.continue hacking
end
Alternativ: (condition ? then clause : else clause)
Sven & Astro () Themenabend Ruby March 28, 2006 35 / 90
![Page 87: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/87.jpg)
if
if Ruby::is cool?applause!
end
if hacker.is hacking?hacker.continue hacking
elsehacker.start hacking
end
unless hacker.is hacking?hacker.start hacking
elsehacker.continue hacking
end
Alternativ: (condition ? then clause : else clause)
Sven & Astro () Themenabend Ruby March 28, 2006 35 / 90
![Page 88: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/88.jpg)
while
i = 0=> 0
while i < 5puts (i += 1)
end
12345=> nil
Abbruch: break
Sven & Astro () Themenabend Ruby March 28, 2006 36 / 90
![Page 89: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/89.jpg)
while
i = 0=> 0
while i < 5puts (i += 1)
end
12345=> nil
Abbruch: break
Sven & Astro () Themenabend Ruby March 28, 2006 36 / 90
![Page 90: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/90.jpg)
while
i = 0=> 0
while i < 5puts (i += 1)
end
12345=> nil
Abbruch: break
Sven & Astro () Themenabend Ruby March 28, 2006 36 / 90
![Page 91: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/91.jpg)
while
i = 0=> 0
while i < 5puts (i += 1)
end
12345=> nil
Abbruch: break
Sven & Astro () Themenabend Ruby March 28, 2006 36 / 90
![Page 92: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/92.jpg)
Hintendran
exit if user.wants to exit?
exit unless user.wants to go on?
i = 0=> 0
beginputs(i+=1)
end while i < 5
12345=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 37 / 90
![Page 93: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/93.jpg)
Hintendran
exit if user.wants to exit?
exit unless user.wants to go on?
i = 0=> 0
beginputs(i+=1)
end while i < 5
12345=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 37 / 90
![Page 94: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/94.jpg)
Hintendran
exit if user.wants to exit?
exit unless user.wants to go on?
i = 0=> 0
beginputs(i+=1)
end while i < 5
12345=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 37 / 90
![Page 95: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/95.jpg)
Hintendran
exit if user.wants to exit?
exit unless user.wants to go on?
i = 0=> 0
beginputs(i+=1)
end while i < 5
12345=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 37 / 90
![Page 96: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/96.jpg)
case
case inputLinewhen "debug"dumpDebugInfodumpSymbols
when /p\s+(\w+)/dumpVariable($1)
when "quit", "exit"exit
elseprint "Illegal command: #{inputLine}"
end
Sven & Astro () Themenabend Ruby March 28, 2006 38 / 90
![Page 97: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/97.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 39 / 90
![Page 98: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/98.jpg)
Der ternare Operator
Bekannt, der ternare Operator:bedingung ? then wert : else wert
4.times { |zahl|puts "#{zahl} " +(zahl == 2 ? ’ist’ : ’ist nicht’) +" Zwei."
}0 ist nicht Zwei.1 ist nicht Zwei.2 ist Zwei.3 ist nicht Zwei.
Sven & Astro () Themenabend Ruby March 28, 2006 40 / 90
![Page 99: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/99.jpg)
Der ternare Operator
Bekannt, der ternare Operator:bedingung ? then wert : else wert
4.times { |zahl|puts "#{zahl} " +(zahl == 2 ? ’ist’ : ’ist nicht’) +" Zwei."
}
0 ist nicht Zwei.1 ist nicht Zwei.2 ist Zwei.3 ist nicht Zwei.
Sven & Astro () Themenabend Ruby March 28, 2006 40 / 90
![Page 100: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/100.jpg)
Der ternare Operator
Bekannt, der ternare Operator:bedingung ? then wert : else wert
4.times { |zahl|puts "#{zahl} " +(zahl == 2 ? ’ist’ : ’ist nicht’) +" Zwei."
}0 ist nicht Zwei.1 ist nicht Zwei.2 ist Zwei.3 ist nicht Zwei.
Sven & Astro () Themenabend Ruby March 28, 2006 40 / 90
![Page 101: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/101.jpg)
Alles hat ein Ergebnis
variable = (if bedingungthen wert
elseelse wert
end)
Sven & Astro () Themenabend Ruby March 28, 2006 41 / 90
![Page 102: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/102.jpg)
Alles hat ein Ergebnis
puts "Zufall " + case randwhen 0..0.3 then "klein"when 0.3..0.7 then "mittel"when 0.7..1 then "gross"else "kaputt"
end
Zufall gross
Zufall klein
Zufall mittel
Sven & Astro () Themenabend Ruby March 28, 2006 42 / 90
![Page 103: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/103.jpg)
Alles hat ein Ergebnis
puts "Zufall " + case randwhen 0..0.3 then "klein"when 0.3..0.7 then "mittel"when 0.7..1 then "gross"else "kaputt"
end
Zufall gross
Zufall klein
Zufall mittel
Sven & Astro () Themenabend Ruby March 28, 2006 42 / 90
![Page 104: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/104.jpg)
Alles hat ein Ergebnis
puts "Zufall " + case randwhen 0..0.3 then "klein"when 0.3..0.7 then "mittel"when 0.7..1 then "gross"else "kaputt"
end
Zufall gross
Zufall klein
Zufall mittel
Sven & Astro () Themenabend Ruby March 28, 2006 42 / 90
![Page 105: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/105.jpg)
Alles hat ein Ergebnis
puts "Zufall " + case randwhen 0..0.3 then "klein"when 0.3..0.7 then "mittel"when 0.7..1 then "gross"else "kaputt"
end
Zufall gross
Zufall klein
Zufall mittel
Sven & Astro () Themenabend Ruby March 28, 2006 42 / 90
![Page 106: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/106.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 43 / 90
![Page 107: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/107.jpg)
Bibliotheken laden
require ’thread’
$: wird durchsucht
Sven & Astro () Themenabend Ruby March 28, 2006 44 / 90
![Page 108: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/108.jpg)
Bibliotheken laden
require ’thread’
$: wird durchsucht
Sven & Astro () Themenabend Ruby March 28, 2006 44 / 90
![Page 109: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/109.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 45 / 90
![Page 110: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/110.jpg)
Methoden
Haben immer einen Ruckgabewert!
def hallo weltputs "Hallo Welt!"
end
hallo welt()Hallo Welt!=> nil
hallo weltHallo Welt!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 46 / 90
![Page 111: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/111.jpg)
Methoden
Haben immer einen Ruckgabewert!
def hallo weltputs "Hallo Welt!"
end
hallo welt()Hallo Welt!=> nil
hallo weltHallo Welt!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 46 / 90
![Page 112: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/112.jpg)
Methoden
Haben immer einen Ruckgabewert!
def hallo weltputs "Hallo Welt!"
end
hallo welt()Hallo Welt!=> nil
hallo weltHallo Welt!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 46 / 90
![Page 113: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/113.jpg)
Parameter
def hallo(whom, bangs)puts "Hallo #{whom}#{’!’*bangs}"
end
hallo ’Peter’, 5Hallo Peter!!!!!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 47 / 90
![Page 114: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/114.jpg)
Parameter
def hallo(whom, bangs)puts "Hallo #{whom}#{’!’*bangs}"
end
hallo ’Peter’, 5Hallo Peter!!!!!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 47 / 90
![Page 115: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/115.jpg)
Default-Parameter
Normaler Parameter darf keinem Default-Parameter folgen!
def hallo(whom=’Eris’)puts "Hallo #{whom}!"
end
hallo ’Peter’Hallo Peter!=> nil
halloHallo Eris!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 48 / 90
![Page 116: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/116.jpg)
Default-Parameter
Normaler Parameter darf keinem Default-Parameter folgen!
def hallo(whom=’Eris’)puts "Hallo #{whom}!"
end
hallo ’Peter’Hallo Peter!=> nil
halloHallo Eris!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 48 / 90
![Page 117: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/117.jpg)
Default-Parameter
Normaler Parameter darf keinem Default-Parameter folgen!
def hallo(whom=’Eris’)puts "Hallo #{whom}!"
end
hallo ’Peter’Hallo Peter!=> nil
halloHallo Eris!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 48 / 90
![Page 118: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/118.jpg)
Variable Parameterliste
def debug parameters(*a)p a
end
debug parameters(23, 5, 42)[23, 5, 42]
Aha, ein Array!
Sven & Astro () Themenabend Ruby March 28, 2006 49 / 90
![Page 119: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/119.jpg)
Variable Parameterliste
def debug parameters(*a)p a
end
debug parameters(23, 5, 42)[23, 5, 42]
Aha, ein Array!
Sven & Astro () Themenabend Ruby March 28, 2006 49 / 90
![Page 120: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/120.jpg)
Parameter als Hash
def hash me(hsh)p hsh
end
hash me ’Datenschleuder’=>2.50, ’Aufkleber’=>1.00{"Aufkleber"=>1.0, "Datenschleuder"=>2.5}hash me(’Datenschleuder’=>2.50, ’Aufkleber’=>1.00){"Aufkleber"=>1.0, "Datenschleuder"=>2.5}
Sven & Astro () Themenabend Ruby March 28, 2006 50 / 90
![Page 121: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/121.jpg)
Parameter als Hash
def hash me(hsh)p hsh
end
hash me ’Datenschleuder’=>2.50, ’Aufkleber’=>1.00{"Aufkleber"=>1.0, "Datenschleuder"=>2.5}hash me(’Datenschleuder’=>2.50, ’Aufkleber’=>1.00){"Aufkleber"=>1.0, "Datenschleuder"=>2.5}
Sven & Astro () Themenabend Ruby March 28, 2006 50 / 90
![Page 122: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/122.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 51 / 90
![Page 123: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/123.jpg)
Blocke
Benutzung: mein array.each { |e| puts e }
def tuyield
end
tu
LocalJumpError: no block givenfrom (irb):2:in ‘tu’from (irb):4from :0
tu { puts ’Hallo’ }Hallo=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 52 / 90
![Page 124: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/124.jpg)
Blocke
Benutzung: mein array.each { |e| puts e }def tuyield
end
tu
LocalJumpError: no block givenfrom (irb):2:in ‘tu’from (irb):4from :0
tu { puts ’Hallo’ }Hallo=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 52 / 90
![Page 125: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/125.jpg)
Blocke
Benutzung: mein array.each { |e| puts e }def tuyield
end
tu
LocalJumpError: no block givenfrom (irb):2:in ‘tu’from (irb):4from :0
tu { puts ’Hallo’ }Hallo=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 52 / 90
![Page 126: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/126.jpg)
Blocke
Benutzung: mein array.each { |e| puts e }def tuyield
end
tu
LocalJumpError: no block givenfrom (irb):2:in ‘tu’from (irb):4from :0
tu { puts ’Hallo’ }Hallo=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 52 / 90
![Page 127: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/127.jpg)
Blocke implizit
def tuyield if block given?
end
tu=> nil
tu { puts ’Hallo’ }Hallo=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 53 / 90
![Page 128: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/128.jpg)
Blocke implizit
def tuyield if block given?
end
tu=> nil
tu { puts ’Hallo’ }Hallo=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 53 / 90
![Page 129: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/129.jpg)
Blocke implizit
def tuyield if block given?
end
tu=> nil
tu { puts ’Hallo’ }Hallo=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 53 / 90
![Page 130: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/130.jpg)
Blocke explizit
def tu(&block)block.call if block
end
tu=> nil
tu { puts ’Hallo’ }Hallo=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 54 / 90
![Page 131: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/131.jpg)
Blocke explizit
def tu(&block)block.call if block
end
tu=> nil
tu { puts ’Hallo’ }Hallo=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 54 / 90
![Page 132: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/132.jpg)
Blocke explizit
def tu(&block)block.call if block
end
tu=> nil
tu { puts ’Hallo’ }Hallo=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 54 / 90
![Page 133: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/133.jpg)
Blocke merken
most important function = lambda { puts "Hello World!" }
most important function.call
Hello World!=> nil
tu { most important function.call }Hello World!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 55 / 90
![Page 134: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/134.jpg)
Blocke merken
most important function = lambda { puts "Hello World!" }most important function.call
Hello World!=> nil
tu { most important function.call }Hello World!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 55 / 90
![Page 135: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/135.jpg)
Blocke merken
most important function = lambda { puts "Hello World!" }most important function.call
Hello World!=> nil
tu { most important function.call }Hello World!=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 55 / 90
![Page 136: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/136.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 56 / 90
![Page 137: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/137.jpg)
Klassen
class Drinkdef initialize(name)@name = name
enddef drinkputs "Drinking #{@name}"
endend
Sven & Astro () Themenabend Ruby March 28, 2006 57 / 90
![Page 138: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/138.jpg)
Vererben
class Mate < Drinkdef initializesuper ’Club Mate’
endend
m = Mate.new=> #<Mate:0x8152664 @name="Club Mate">
m.drinkDrinking Club Mate=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 58 / 90
![Page 139: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/139.jpg)
Vererben
class Mate < Drinkdef initializesuper ’Club Mate’
endend
m = Mate.new=> #<Mate:0x8152664 @name="Club Mate">
m.drinkDrinking Club Mate=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 58 / 90
![Page 140: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/140.jpg)
Vererben
class Mate < Drinkdef initializesuper ’Club Mate’
endend
m = Mate.new=> #<Mate:0x8152664 @name="Club Mate">
m.drinkDrinking Club Mate=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 58 / 90
![Page 141: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/141.jpg)
Getter
class Drinkattr reader :name
end
m.name=> "Club Mate"
m.name = ’B33r’NoMethodError: undefined method ‘name=’ for#<Mate:0x8152664 @name="Club Mate">from (irb):38from :0
Sven & Astro () Themenabend Ruby March 28, 2006 59 / 90
![Page 142: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/142.jpg)
Getter
class Drinkattr reader :name
end
m.name=> "Club Mate"
m.name = ’B33r’NoMethodError: undefined method ‘name=’ for#<Mate:0x8152664 @name="Club Mate">from (irb):38from :0
Sven & Astro () Themenabend Ruby March 28, 2006 59 / 90
![Page 143: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/143.jpg)
Getter
class Drinkattr reader :name
end
m.name=> "Club Mate"
m.name = ’B33r’NoMethodError: undefined method ‘name=’ for#<Mate:0x8152664 @name="Club Mate">from (irb):38from :0
Sven & Astro () Themenabend Ruby March 28, 2006 59 / 90
![Page 144: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/144.jpg)
Getter & Setter
class Drinkattr accessor :name
end
m.name=> "Club Mate"
m.name = ’Jolt’=> "Jolt"
m.name=> "Jolt"
Sven & Astro () Themenabend Ruby March 28, 2006 60 / 90
![Page 145: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/145.jpg)
Getter & Setter
class Drinkattr accessor :name
end
m.name=> "Club Mate"
m.name = ’Jolt’=> "Jolt"
m.name=> "Jolt"
Sven & Astro () Themenabend Ruby March 28, 2006 60 / 90
![Page 146: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/146.jpg)
Getter & Setter
class Drinkattr accessor :name
end
m.name=> "Club Mate"
m.name = ’Jolt’=> "Jolt"
m.name=> "Jolt"
Sven & Astro () Themenabend Ruby March 28, 2006 60 / 90
![Page 147: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/147.jpg)
Getter & Setter
class Drinkattr accessor :name
end
m.name=> "Club Mate"
m.name = ’Jolt’=> "Jolt"
m.name=> "Jolt"
Sven & Astro () Themenabend Ruby March 28, 2006 60 / 90
![Page 148: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/148.jpg)
Getter und Setter selbst bauen
class Drinkdef initialize(erster name)self.name = erster name
enddef name@name
enddef name=(neuer name)if neuer name == ’Beer’raise ’Please stay sober while coding’
else@name = neuer name
endend
end
Sven & Astro () Themenabend Ruby March 28, 2006 61 / 90
![Page 149: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/149.jpg)
Getter und Setter selbst bauen
m = Drink.new(’Mate’)=> #<Drink:0x812cef0 @name="Mate">
m.name = ’Milk’=> "Milk"
m.name = ’Beer’RuntimeError: Please stay sober while codingfrom (irb):7:in ‘name=’from (irb):14from :0
b = Drink.new(’Beer’)RuntimeError: Please stay sober while codingfrom (irb):7:in ‘name=’from (irb):17:in ‘initialize’from (irb):20from :0
Sven & Astro () Themenabend Ruby March 28, 2006 62 / 90
![Page 150: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/150.jpg)
Getter und Setter selbst bauen
m = Drink.new(’Mate’)=> #<Drink:0x812cef0 @name="Mate">
m.name = ’Milk’=> "Milk"
m.name = ’Beer’RuntimeError: Please stay sober while codingfrom (irb):7:in ‘name=’from (irb):14from :0
b = Drink.new(’Beer’)RuntimeError: Please stay sober while codingfrom (irb):7:in ‘name=’from (irb):17:in ‘initialize’from (irb):20from :0
Sven & Astro () Themenabend Ruby March 28, 2006 62 / 90
![Page 151: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/151.jpg)
Getter und Setter selbst bauen
m = Drink.new(’Mate’)=> #<Drink:0x812cef0 @name="Mate">
m.name = ’Milk’=> "Milk"
m.name = ’Beer’RuntimeError: Please stay sober while codingfrom (irb):7:in ‘name=’from (irb):14from :0
b = Drink.new(’Beer’)RuntimeError: Please stay sober while codingfrom (irb):7:in ‘name=’from (irb):17:in ‘initialize’from (irb):20from :0
Sven & Astro () Themenabend Ruby March 28, 2006 62 / 90
![Page 152: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/152.jpg)
Klassen erweitern
Dringend benotigte Funktionen
Flicken von fehlerhaftem Fremdcode
Verstreuen der Implementation auf mehrere Dateien
Beispielproblem von turbo24prg: String#to b
class Stringdef to bself == ’true’
endend
’chunky bacon’.to b=> false
’true’.to b=> true
Sven & Astro () Themenabend Ruby March 28, 2006 63 / 90
![Page 153: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/153.jpg)
Klassen erweitern
Dringend benotigte Funktionen
Flicken von fehlerhaftem Fremdcode
Verstreuen der Implementation auf mehrere Dateien
Beispielproblem von turbo24prg: String#to b
class Stringdef to bself == ’true’
endend
’chunky bacon’.to b=> false
’true’.to b=> true
Sven & Astro () Themenabend Ruby March 28, 2006 63 / 90
![Page 154: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/154.jpg)
Klassen erweitern
Dringend benotigte Funktionen
Flicken von fehlerhaftem Fremdcode
Verstreuen der Implementation auf mehrere Dateien
Beispielproblem von turbo24prg: String#to b
class Stringdef to bself == ’true’
endend
’chunky bacon’.to b=> false
’true’.to b=> true
Sven & Astro () Themenabend Ruby March 28, 2006 63 / 90
![Page 155: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/155.jpg)
Klassen erweitern
Dringend benotigte Funktionen
Flicken von fehlerhaftem Fremdcode
Verstreuen der Implementation auf mehrere Dateien
Beispielproblem von turbo24prg: String#to b
class Stringdef to bself == ’true’
endend
’chunky bacon’.to b=> false
’true’.to b=> true
Sven & Astro () Themenabend Ruby March 28, 2006 63 / 90
![Page 156: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/156.jpg)
Object#method missing
class MeineKlassedef method missing(*a)p a
endend
k = MeineKlasse.new=> #<MeineKlasse:0x813db38>
k.hello[:hello]=> nil
k.hello(23, 42)[:hello, 23, 42]=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 64 / 90
![Page 157: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/157.jpg)
Object#method missing
class MeineKlassedef method missing(*a)p a
endend
k = MeineKlasse.new=> #<MeineKlasse:0x813db38>
k.hello[:hello]=> nil
k.hello(23, 42)[:hello, 23, 42]=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 64 / 90
![Page 158: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/158.jpg)
Object#method missing
class MeineKlassedef method missing(*a)p a
endend
k = MeineKlasse.new=> #<MeineKlasse:0x813db38>
k.hello[:hello]=> nil
k.hello(23, 42)[:hello, 23, 42]=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 64 / 90
![Page 159: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/159.jpg)
Object#method missing
class MeineKlassedef method missing(*a)p a
endend
k = MeineKlasse.new=> #<MeineKlasse:0x813db38>
k.hello[:hello]=> nil
k.hello(23, 42)[:hello, 23, 42]=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 64 / 90
![Page 160: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/160.jpg)
”Builder”
class Builderdef self.printputs yield(new)
enddef method missing(fname, attrs={})"<#{fname}" + attrs.collect { |k,v| " #{k}=\"#{v}\""
}.to s + (block given? ? ">#{yield}</#{fname}>" :’/>’)end
end
Sven & Astro () Themenabend Ruby March 28, 2006 65 / 90
![Page 161: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/161.jpg)
”Builder” angewandt
Builder.print { |b|b.html {b.head {b.title {’Hello World!’
}} +b.body {b.input ’name’=>’search’
}}
}
<html><head><title>HelloWorld!</title></head><body><inputname="search"/></body></html>
Sven & Astro () Themenabend Ruby March 28, 2006 66 / 90
![Page 162: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/162.jpg)
”Builder” angewandt
Builder.print { |b|b.html {b.head {b.title {’Hello World!’
}} +b.body {b.input ’name’=>’search’
}}
}<html><head><title>HelloWorld!</title></head><body><inputname="search"/></body></html>
Sven & Astro () Themenabend Ruby March 28, 2006 66 / 90
![Page 163: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/163.jpg)
Getter definieren mit Module#define method
class MeineKlassedef initialize@variable = ’hallo’
enddefine method(:var) do@variable
endend
m = MeineKlasse.new=> #<MeineKlasse:0x8060bf4 @variable="hallo">
m.var=> "hallo"
Sven & Astro () Themenabend Ruby March 28, 2006 67 / 90
![Page 164: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/164.jpg)
Getter definieren mit Module#define method
class MeineKlassedef initialize@variable = ’hallo’
enddefine method(:var) do@variable
endend
m = MeineKlasse.new=> #<MeineKlasse:0x8060bf4 @variable="hallo">
m.var=> "hallo"
Sven & Astro () Themenabend Ruby March 28, 2006 67 / 90
![Page 165: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/165.jpg)
Getter definieren mit Module#define method
class MeineKlassedef initialize@variable = ’hallo’
enddefine method(:var) do@variable
endend
m = MeineKlasse.new=> #<MeineKlasse:0x8060bf4 @variable="hallo">
m.var=> "hallo"
Sven & Astro () Themenabend Ruby March 28, 2006 67 / 90
![Page 166: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/166.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 68 / 90
![Page 167: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/167.jpg)
Module und Namensaume
module Jabberclass Clientdef initialize# Code
endend
end
client = Jabber::Client.new
Sven & Astro () Themenabend Ruby March 28, 2006 69 / 90
![Page 168: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/168.jpg)
Module und Namensaume
module Jabberclass Clientdef initialize# Code
endend
end
client = Jabber::Client.new
Sven & Astro () Themenabend Ruby March 28, 2006 69 / 90
![Page 169: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/169.jpg)
Module und Mixins
module Eatabledef eatputs "#{self.class} #{@name} has been eaten."
endend
class Fryhstyckinclude Eatabledef initialize@name = ’Egg and Ham’
endend
f = Fryhstyck.new=> #<Fryhstyck:0x811e378 @name="Egg and Ham">
f.eatFryhstyck Egg and Ham has been eaten.=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 70 / 90
![Page 170: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/170.jpg)
Module und Mixins
module Eatabledef eatputs "#{self.class} #{@name} has been eaten."
endend
class Fryhstyckinclude Eatabledef initialize@name = ’Egg and Ham’
endend
f = Fryhstyck.new=> #<Fryhstyck:0x811e378 @name="Egg and Ham">
f.eatFryhstyck Egg and Ham has been eaten.=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 70 / 90
![Page 171: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/171.jpg)
Module und Mixins
module Eatabledef eatputs "#{self.class} #{@name} has been eaten."
endend
class Fryhstyckinclude Eatabledef initialize@name = ’Egg and Ham’
endend
f = Fryhstyck.new=> #<Fryhstyck:0x811e378 @name="Egg and Ham">
f.eatFryhstyck Egg and Ham has been eaten.=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 70 / 90
![Page 172: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/172.jpg)
Module und Mixins
module Eatabledef eatputs "#{self.class} #{@name} has been eaten."
endend
class Fryhstyckinclude Eatabledef initialize@name = ’Egg and Ham’
endend
f = Fryhstyck.new=> #<Fryhstyck:0x811e378 @name="Egg and Ham">
f.eatFryhstyck Egg and Ham has been eaten.=> nil
Sven & Astro () Themenabend Ruby March 28, 2006 70 / 90
![Page 173: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/173.jpg)
Modulmethoden
module MeinModuldef MeinModul.homelessputs "I’ve got no instance"
endend
MeinModul.homelessI’ve got no instance
Sven & Astro () Themenabend Ruby March 28, 2006 71 / 90
![Page 174: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/174.jpg)
Modulmethoden
module MeinModuldef MeinModul.homelessputs "I’ve got no instance"
endend
MeinModul.homelessI’ve got no instance
Sven & Astro () Themenabend Ruby March 28, 2006 71 / 90
![Page 175: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/175.jpg)
Klassenmethoden
class MeineKlassedef self.neunew
endend
MeineKlasse.neu=> #<MeineKlasse:0x810d3fc>
class MeineKindklasse < MeineKlasseend
MeineKindklasse.neu=> #<MeineKindklasse:0x814e500>
Sven & Astro () Themenabend Ruby March 28, 2006 72 / 90
![Page 176: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/176.jpg)
Klassenmethoden
class MeineKlassedef self.neunew
endend
MeineKlasse.neu=> #<MeineKlasse:0x810d3fc>
class MeineKindklasse < MeineKlasseend
MeineKindklasse.neu=> #<MeineKindklasse:0x814e500>
Sven & Astro () Themenabend Ruby March 28, 2006 72 / 90
![Page 177: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/177.jpg)
Klassenmethoden
class MeineKlassedef self.neunew
endend
MeineKlasse.neu=> #<MeineKlasse:0x810d3fc>
class MeineKindklasse < MeineKlasseend
MeineKindklasse.neu=> #<MeineKindklasse:0x814e500>
Sven & Astro () Themenabend Ruby March 28, 2006 72 / 90
![Page 178: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/178.jpg)
Klassenmethoden
class MeineKlassedef self.neunew
endend
MeineKlasse.neu=> #<MeineKlasse:0x810d3fc>
class MeineKindklasse < MeineKlasseend
MeineKindklasse.neu=> #<MeineKindklasse:0x814e500>
Sven & Astro () Themenabend Ruby March 28, 2006 72 / 90
![Page 179: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/179.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 73 / 90
![Page 180: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/180.jpg)
Exceptions
beginf = File.new(’/nonexistant/imaginary file’)
rescueputs "Fehler: #{$!}"
end
Fehler: No such file or directory -/nonexistant/imaginary file
Sven & Astro () Themenabend Ruby March 28, 2006 74 / 90
![Page 181: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/181.jpg)
Exceptions
beginf = File.new(’/nonexistant/imaginary file’)
rescueputs "Fehler: #{$!}"
end
Fehler: No such file or directory -/nonexistant/imaginary file
Sven & Astro () Themenabend Ruby March 28, 2006 74 / 90
![Page 182: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/182.jpg)
Exceptions: Begrenzen
beginf = File.new(’/nonexistant/imaginary file’)
rescue Errno => ep e
end
Errno::ENOENT: No such file or directory -/nonexistant/imaginary filefrom (irb):2:in ‘initialize’from (irb):2from :0
Sven & Astro () Themenabend Ruby March 28, 2006 75 / 90
![Page 183: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/183.jpg)
Exceptions: Begrenzen
beginf = File.new(’/nonexistant/imaginary file’)
rescue Errno => ep e
end
Errno::ENOENT: No such file or directory -/nonexistant/imaginary filefrom (irb):2:in ‘initialize’from (irb):2from :0
Sven & Astro () Themenabend Ruby March 28, 2006 75 / 90
![Page 184: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/184.jpg)
Exceptions: Syntaxfehler
beginxxx
rescue Exception => eputs "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
end
NameError: undefined local variable or method ‘xxx’for main:Object(irb):7:in ‘irb binding’/usr/local/lib/ruby/1.8/irb/workspace.rb:52:in‘irb binding’:0
Sven & Astro () Themenabend Ruby March 28, 2006 76 / 90
![Page 185: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/185.jpg)
Exceptions: Syntaxfehler
beginxxx
rescue Exception => eputs "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
end
NameError: undefined local variable or method ‘xxx’for main:Object(irb):7:in ‘irb binding’/usr/local/lib/ruby/1.8/irb/workspace.rb:52:in‘irb binding’:0
Sven & Astro () Themenabend Ruby March 28, 2006 76 / 90
![Page 186: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/186.jpg)
Exceptions: Mehr
begin# Ausnahmenwerfender Code
ensure# Was auf jeden Fall gemacht werden muss
end
raise "Computer gone. No processor to run on left."
raise NotImplementedError.new(’Programmer too lazy’)
Nochmal ausfuhren: retry
Sven & Astro () Themenabend Ruby March 28, 2006 77 / 90
![Page 187: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/187.jpg)
Exceptions: Mehr
begin# Ausnahmenwerfender Code
ensure# Was auf jeden Fall gemacht werden muss
end
raise "Computer gone. No processor to run on left."
raise NotImplementedError.new(’Programmer too lazy’)
Nochmal ausfuhren: retry
Sven & Astro () Themenabend Ruby March 28, 2006 77 / 90
![Page 188: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/188.jpg)
Exceptions: Mehr
begin# Ausnahmenwerfender Code
ensure# Was auf jeden Fall gemacht werden muss
end
raise "Computer gone. No processor to run on left."
raise NotImplementedError.new(’Programmer too lazy’)
Nochmal ausfuhren: retry
Sven & Astro () Themenabend Ruby March 28, 2006 77 / 90
![Page 189: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/189.jpg)
Upcoming...
2 EinfuhrungMetaHilfe?irb & riVariablenAlles ist ein ObjektKonventionenprint-DebuggingPrimitive DatentypenKontrollstrukturenAlles hat ein ErgebnisBibliotheken ladenMethodenBlockeKlassenModuleExceptionsDesign Patterns
Sven & Astro () Themenabend Ruby March 28, 2006 78 / 90
![Page 190: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/190.jpg)
Factory method
def factory methodConcreteProduct.new
end
Sven & Astro () Themenabend Ruby March 28, 2006 79 / 90
![Page 191: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/191.jpg)
Observer
require ’observer’
module Observable als Mixin
Sven & Astro () Themenabend Ruby March 28, 2006 80 / 90
![Page 192: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/192.jpg)
Singleton
require ’observer’
module Singleton als Mixin
Sven & Astro () Themenabend Ruby March 28, 2006 81 / 90
![Page 193: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/193.jpg)
Decorator
Object#extend
Sven & Astro () Themenabend Ruby March 28, 2006 82 / 90
![Page 194: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/194.jpg)
Upcoming...
3 Ruby-MediaWikiMediaWiki?Ruby-MediaWiki!
Sven & Astro () Themenabend Ruby March 28, 2006 83 / 90
![Page 195: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/195.jpg)
MediaWiki?
Sven & Astro () Themenabend Ruby March 28, 2006 84 / 90
![Page 196: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/196.jpg)
MediaWiki?
Sven & Astro () Themenabend Ruby March 28, 2006 85 / 90
![Page 197: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/197.jpg)
MediaWiki?
Sven & Astro () Themenabend Ruby March 28, 2006 86 / 90
![Page 198: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/198.jpg)
Upcoming...
3 Ruby-MediaWikiMediaWiki?Ruby-MediaWiki!
Sven & Astro () Themenabend Ruby March 28, 2006 87 / 90
![Page 199: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/199.jpg)
Ruby-MediaWiki!
Sven & Astro () Themenabend Ruby March 28, 2006 88 / 90
![Page 200: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/200.jpg)
Ruby-MediaWiki!
Sven & Astro () Themenabend Ruby March 28, 2006 89 / 90
![Page 201: Themenabend Ruby - c3d2 · SWIG interface is also available. Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances](https://reader036.fdocuments.net/reader036/viewer/2022081611/5f074bd47e708231d41c484d/html5/thumbnails/201.jpg)
Ruby-MediaWiki!
Sven & Astro () Themenabend Ruby March 28, 2006 90 / 90