AaronHopkins's Profile User Rating: -----

Reputation: -1 Dishonored
Group:
Active Members
Active Posts:
182 (0.1 per day)
Joined:
01-March 11
Profile Views:
1,971
Last Active:
User is offline Sep 29 2014 07:43 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   AaronHopkins has not set their status

Posts I've Made

  1. In Topic: Ruby - Compare Integers by Divisiblity of 2

    Posted 15 Sep 2014

    I have to use <=> & i cant use Fixnum though.
  2. In Topic: Ruby - Compare Integers by Divisiblity of 2

    Posted 15 Sep 2014

    so would something like this help?

    	def <=>(compare)
    		divisibleBy2(int) <=> compare.divisibleBy2(compare.int)
    


    it's printing out 4 >10 = false when it should be true
  3. In Topic: Ruby - Compare Integers by Divisiblity of 2

    Posted 15 Sep 2014

    class Integer
    	include Comparable
    	attr :int
    
    	def <=>(compare)
    		divisbleBy2 <=> compare.divisibleBy2(compare.int)
    	end
    
    	def initialize(int)
    		@int = int
    	end
    
    	def inspect
        		@int
    	end
    end
    
    
    def divisibleBy2(x)
    	i = 0
    	while x % 2 == 0
    		x = x/2
    		i = i + 1
    	end
    	return i
    end
    
    int1 = Integer.new(4)
    int2 = Integer.new(10)
    
    print(int1, " > ", int2, " = ", int1 > int2, "\n")
    


    I feel i'm so close, yet i'm getting the error of:
    undefined method 'new' for Integer:Class
    


    Keep in mind, I have to use that Integer class & not fixnum

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

AaronHopkins hasn't added any friends yet.

Comments

AaronHopkins has no profile comments yet. Why not say hello?