Have fun-with-ruby

Preview:

Citation preview

自己紹介

名前: 日本語: グエン・ヴァン・ドゥック ベトナム語: Nguyễn Văn Đức

ニックネーム : レン年齢: 23 際大学:ハノイ工科大学趣味:スポーツ、 PC ゲーム

Get start

Have fun with Ruby

Table of contents

1.Ruby in normaly

2.How to program Ruby without using any numbers or letters

3.Summary

1.Ruby in normaly

1.Ruby in normaly

階乗 n! を計算する1. Variable2. Method3. Number value4. String5. Structure6. Output

2. How to use Ruby without using any numbers or letters

1. Variable

In the normal case

my_number = 2

Without using letter Ruby に「 _ 」とか「 $ 」などでVariable が作られます my_number = 2

<=> _ = 2

2. How to use Ruby without using any numbers or letters

2. How to use Ruby without using any numbers or letters

2. Numberpid -> Integer

カレントプロセスのプロセス ID を返します。変数 $$ の値と同じです。$$ の値はいつも != 0

+,-,x,/, << で任意ナンバーが作られます。$$ / $$ = 1 $$ - $$ = 0

2. How to use Ruby without using any numbers or letters

2. Numbermy_number = 2 は _ = $$ / $$ + $$ / $$ になります。

2. How to use Ruby without using any numbers or letters

3. Stringmy_string = "basic"

"basic" = "b" << "a" << "s" << "i" << "c"

ASCII に基づけ ASCII コードを使って、 String が作られます。"b" << "a" << "s" << "i" << "c" <=> '' << 98 << 97 << 115 <<105 << 99

2. How to use Ruby without using any numbers or letters

3. String結果:__ = '' << 98 << 97 << 115 <<105 << 99

2. How to use Ruby without using any numbers or letters

4. Method

メソッドの理想 “package code first, call it later”

Proc とほぼ一緒です。 my_proc = Proc.new{|x| x + 1; p x} ... # more code my_proc.call(2) #=> 3

2. How to use Ruby without using any numbers or letters

4. Method文字と数字を削除する_ = $$/$$___ = Proc.new{|__| __ + _; p __}

... # more code

___.call(_+_) #=> 3

my_proc = Proc.new{|x| x + 1; p x} ... # more code my_proc.call(2) #=> 3

Proc.new の代わりに、 -> シンボルが作られます。call 使わず、 [] シンボルが作られます。

2. How to use Ruby without using any numbers or letters

4. Method結果:

_ = $$/$$

___ = -> {|__| __ + _; p __}

... # more code

___.[(_+_)] #=> 3

my_proc = Proc.new{|x| x + 1; p x} ... # more code my_proc.call(2) #=> 3

ほぼ完了しました。

2. How to use Ruby without using any numbers or letters

5. Structureどんな言語でも、 Structure の種類は3つがあります。

1. Sequence

2. Selection

3. Iteration

2. How to use Ruby without using any numbers or letters

5.1. Sequencesequence では , 普通な実装です。上から下までで実行します。

=> 問題ない。

2. How to use Ruby without using any numbers or letters

5.2. Selection

文字禁止なので、 if-esle が使えない。だが、 if-else の代わりに、?:のシンタックスで置き換えることができます

2. How to use Ruby without using any numbers or letters

5.3. Interation

ループを作るために、再帰と Proc シンタックスを兼ねる。。普段: (1..10).each do |x|

p xend

(___ = -> { x += 1 p x x <= 10 ? ___[] : 0})[]

2. How to use Ruby without using any numbers or letters

6. Output今まで、結果を表示するために、 puts のコマンドを作っています。Ruby に $> シンボルは puts の使い方と同じです。puts "basic" <=> $> '' << 98 << 97 << 115 <<105 << 99 # => basic

3. Summary

3.1 Example

3. Summary

3.1 Example

3. Summary

3.2. Summary

for Fun and Not Much Else!!

3. Summary

ご清聴ありがとうございます。

Recommended