2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VBScriptとRubyで簡単な処理を書いて比較してみる

Last updated at Posted at 2016-05-09

VBScriptとRubyの比較

ふと、VBSciptとRubyで同じ処理を書いたらどのくらい短くなるのだろうと思ったので試してみた。

「5回入力をして、その合計を足す」という簡単な例。

VBSciprt
Dim i, r
r = 0
For i = 1 To 5
   r = r + CInt(WScript.StdIn.ReadLine)
Next
WScript.Echo r
Ruby
puts 5.times.map{gets.to_i}.reduce(&:+)

行数こそ6行と1行だけれども、文字数はざっくり、VBScriptが78文字くらいで、Rubyが39文字くらい。半分ですね。

だからどうだということはないんですが、なんとなく比較してみたくなったので比較してみました(^^;

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?