The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Rubyize this: Live in Vancouver. Refactoring #1.

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Patten

Posts: 43
Nickname: spatten
Registered: Jan, 2008

Scott Patten is a freelance web developer and Ruby on Rails trainer based in Vancouver
Rubyize this: Live in Vancouver. Refactoring #1. Posted: Jan 26, 2008 5:34 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Scott Patten.
Original Post: Rubyize this: Live in Vancouver. Refactoring #1.
Feed Title: Scott Patten's Blog
Feed URL: http://feeds.feedburner.com/scottpatten.ca
Feed Description: Scott Patten is the cofounder of Ruboss (http://ruboss.com) and Leanpub (http://leanpub.com), both based in Vancouver. He is also the author of The S3 Cookbook (http://leanpub.com/thes3cookbook). He blogs about Startups, Ruby, Rails, Javascript, CSS, Amazon Web Services and whatever else strikes his fancy.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Scott Patten
Latest Posts From Scott Patten's Blog

Advertisement

First refactoring:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env ruby

# create num random numbers between min and max 
# and print them to a file called file_name, one per line
def create_random_numbers(file_name, min, max, num)
  file = File.open(file_name, 'w')
  n = 0
  while n < num
    r = rand(max - min) + min
    file.puts(r)
    n += 1
  end
  file.close   
end

create_random_numbers('random.txt', 0, 10, 1000)

Read: Rubyize this: Live in Vancouver. Refactoring #1.

Topic: Where? Join us at WorkSpace @ 400 – 21 Water St in Downtown Vancouver Previous Topic   Next Topic Topic: Renum goes one-oh with a nice new syntax for an important new feature

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use