Upload
ken-lauren-daganio
View
442
Download
2
Embed Size (px)
Citation preview
RUBY + RAILSA really tiny introduction.
FEU - East Asia College — 11 February 2014
こ ん に ち は ル ビ ー
LEARN
LEARNby example :)
ハローワールド
public class Hello {! public static void main(String[] args) {! System.out.println(“Ohayou, Ruby!”);! }!}
Hello.java
ハローワールド
public class Hello {! public static void main(String[] args) {! System.out.println(“Ohayou, Ruby!”);! }!}
puts “Ohayou Ruby!”
Hello.java
hello.rb
ハローワールド
public class Hello {! public static void main(String[] args) {! System.out.println(“Ohayou, Ruby!”);! }!}
puts “Ohayou Ruby!”
Hello.java
hello.rb
110
ハローワールド
public class Hello {! public static void main(String[] args) {! System.out.println(“Ohayou, Ruby!”);! }!}
puts “Ohayou Ruby!”
Hello.java
hello.rb
110
19
578 %Productivity Gain
578 %Productivity Gain
(I don’t really know what I’m doing.)
反復するpublic class Loop {! public static void main(String[] args) {!! ! String fruits[] = new String[]{“apple”, “orange”}! for(int i = 0; i < fruits.length; i++){!! ! ! System.out.println(fruit[i]);!! ! }! }!}
Loop.java
反復するpublic class Loop {! public static void main(String[] args) {!! ! String fruits[] = new String[]{“apple”, “orange”}! for(int i = 0; i < fruits.length; i++){!! ! ! System.out.println(fruit[i]);!! ! }! }!}
fruits = [“apple”, “orange”]!fruits.each do |fruit| !! puts fruit !end
Loop.java
loop.rb
反復するpublic class Loop {! public static void main(String[] args) {!! ! String fruits[] = new String[]{“apple”, “orange”}! for(int i = 0; i < fruits.length; i++){!! ! ! System.out.println(fruit[i]);!! ! }! }!}
[“apple”, “orange”].each do |fruit| !! puts fruit !end
Loop.java
loop.rb
反復するpublic class Loop {! public static void main(String[] args) {!! ! String fruits[] = new String[]{“apple”, “orange”}! for(int i = 0; i < fruits.length; i++){!! ! ! System.out.println(fruit[i]);!! ! }! }!}
[“apple”, “orange”].each { |fruit| puts fruit }
Loop.java
loop.rb
条件付きの
if(age < 18)!! puts “Minor!”;!elsif(age >= 60)!! puts “Senior”;!elsif(age >= 18 && age < 60)!! puts “Legal Age”;
can_i_go_to_the_club.rb
条件付きの
if(age < 18)!! puts “Minor!”!elsif(age >= 60)!! puts “Senior”!elsif(age >= 18 && age < 60)!! puts “Legal Age”
can_i_go_to_the_club.rb
条件付きの
if age < 18!! puts “Minor!”!elsif age >= 60!! puts “Senior”!elsif age >= 18 && age < 60!! puts “Legal Age”
can_i_go_to_the_club.rb
条件付きの
if age < 18!! puts “Minor!”!elsif age >= 60!! puts “Senior”!elsif age >= 18 and age < 60!! puts “Legal Age”
can_i_go_to_the_club.rb
コレクション
passed = [] !!students.each do |student|!! if score > 70!! ! passed << student!! end!end
you_shall_not_pass.rb
コレクション
passed = students.map { |s| s.score > 70 }!passed = students.collect { |s| s.score > 70 }!!— OR — !!passed = students.delete_if { |s| s.score <= 70 }!passed = students.reject { |s| s.score <= 70 }
you_shall_not_pass.rb
RUBY ON RAILS
DEMO TIEM!
RESOURCES
• https://www.ruby-lang.org/en/
• http://guides.rubyonrails.org/
• http://railscasts.com/
• http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
• http://ruby.learncodethehardway.org/
SLIDEShttp://slidesha.re/1cq6fkn
THANK YOU!Ken-Lauren Daganio
@kendaganio