Ad
  • Default User Avatar

    True, but an array can be initialized with null, then you will get NullPointerException:

    String[] test = null;

    and considering there was a test

    @Test
    public void validateNull() {
    	assertNull(SmashWords.smash(null));
    }
    

    i'd go for a null check before returning.

  • Custom User Avatar

    One of the assumptions in the details was the you were given an array.

  • Custom User Avatar

    That error IS strange. Unfortunately I have no idea what to debug. Can you please share your code? You can mark it as a spoiler and it should stay hidden.

  • Default User Avatar

    Thank you! I'll stick toLowerCamelCaseFromNowOn ;)

  • Default User Avatar

    @liry

    Thanks for feedback!
    What is the current standard in Java to start member names? Or there is none? (Please do not direct me to stack-overflow-like-pages because the answers there are very inconsistent ;) )
    All info appreciated.

    I am a C# developer trying out Java and ... old habits die hard ;)

  • Custom User Avatar

    You're right. I forgot to pass the initial 0 to inject. Should have been:
    def squareSum(numbers)
    numbers.inject(0) { |sum,x| sum + x**2 }
    end