-- Can sombody please break these down and let me know what each line of
these examples are doing. I've used c++ a little, but I'm new to Ruby.
Any response would be greatly appreciated.






def pow(base, exponent)
  result = 1

  i = 1
  while i <= exponent
    result = result * base
    i += 1
  end

  result
end

------------------------------------
def sum(nums)
  total = 0

  i = 0
  while i < nums.count
    total += nums[i]

    i += 1
  end

  # return total
  total
end

-------------------------------------
def is_prime?(num)
  i = 2
  while i < num
    is_divisible = ((num % i) == 0)

    if is_divisible
      # divisor found; stop and return false!
      return false
    end

    i += 1
  end

  # no divisors found
  true
end
-------------------------------------
def primes(max)
  primes_arr = []

  i = 2
  while i < max
    if is_prime?(i)
      # i is prime; add it to the array
      primes_arr << i
    end

    i += 1
  end

  # return primes_arr
  primes_arr
end

-- 
Posted via http://www.ruby-forum.com/.