Slide 1

Slide 1 text

RUBY zach latta a hands-on introduction to

Slide 2

Slide 2 text

ruby is a high productivity scripting language

Slide 3

Slide 3 text

Japan made in designed by matsumoto yukihiro

Slide 4

Slide 4 text

matz

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

...and many more

Slide 10

Slide 10 text

it’s fun idiomatic poignant not java

Slide 11

Slide 11 text

objects. objects everywhere.

Slide 12

Slide 12 text

1 "DO NOT USE ALL CAPS".downcase => "do not use all caps" valid ruby 2 5.rationalize => (5/1)

Slide 13

Slide 13 text

i can’t believe it’s not english!

Slide 14

Slide 14 text

1 5.times { print "hi" } => "hihihihihi" print “hi” five times 2 print "hi" * 5 => "hihihihihi"

Slide 15

Slide 15 text

1 import java.io.* 2 3 public class Hi 4 { 5 public static void main(String[] args) 6 { 7 for (int i = 0; i < 5; i++) 8 { 9 System.out.print("hi"); 10 } 11 } 12 } …and in java

Slide 16

Slide 16 text

quickly and easily understand other ruby

Slide 17

Slide 17 text

1 print 'This is not a '\ 'palindrome'.reverse => "emordnilap a ton si sihT"

Slide 18

Slide 18 text

“code so beautiful that tears are shed” - why’s poignant guide to ruby

Slide 19

Slide 19 text

1 puts "What is your name?" 2 name = gets.strip! 3 4 puts "Hello #{ name }. How are you?" greetings

Slide 20

Slide 20 text

! 1 import java.util.Scanner; 2 3 public class ALessNiceGreeting 4 { 5 public static void main(String[] args) 6 { 7 Scanner scanner = new Scanner(System.in); 8 9 System.out.println("What is your name?"); 10 String name = scanner.nextLine().trim(); 11 12 System.out.println("Hi " + name + ". How are you?"); 13 14 scanner.close(); 15 } 16 } greetings (cont.)

Slide 21

Slide 21 text

1 contents = File.read('file.txt') 2 puts contents file io

Slide 22

Slide 22 text

1 import java.io.BufferedReader; 2 import java.io.FileReader; 3 import java.io.IOException; 4 5 public class BufferedReaderExample 6 { 7 public static void main(String[] args) 8 { 9 BufferedReader br = null; 10 11 try 12 { 13 14 String sCurrentLine; 15 16 br = new BufferedReader(new FileReader("file.txt")); 17 18 while ((sCurrentLine = br.readLine()) != null) 19 { 20 System.out.println(sCurrentLine); 21 } 22 23 } 24 catch (IOException e) 25 { 26 e.printStackTrace(); 27 } 28 finally 29 { 30 try 31 { 32 if (br != null)br.close(); 33 } 34 catch (IOException ex) 35 { 36 ex.printStackTrace(); 37 } 38 } 39 40 } 41 } file io (cont.)

Slide 23

Slide 23 text

power simplicity vs.

Slide 24

Slide 24 text

1 def a_method 2 puts "Hello world!" 3 end methods

Slide 25

Slide 25 text

1 get ‘/‘ do 2 'Hello world!' 3 end dsl

Slide 26

Slide 26 text

gems

Slide 27

Slide 27 text

bogosort while !sorted(deck) { shuffle(deck) }

Slide 28

Slide 28 text

bogosort best case: ΩΩ(n) worst case: Unbounded average case: O(n × n!)

Slide 29

Slide 29 text

• http://mislav.uniqpath.com/ poignant-guide/ • http://tryruby.org • make something!

Slide 30

Slide 30 text

github.com/zachlatta/baas speakerdeck.com/zach/a- hands-on-introduction-to-ruby

Slide 31

Slide 31 text

[email protected] e: w: zachlatta.com g: github.com/zachlatta