Ad
  • Default User Avatar

    Was just thinking it could return true or false even in a null case.

    It doesn't make any sense without any context. A string neither does nor does not end with no-one-knows-what. Returning a value is just hiding an error that someone (maybe you) will have to find one day when something weird happens because of it.

    Null ending parameter is (gracefully) handled

    ?
    It's handled the same way as a null str.

  • Default User Avatar

    It is handled: an exception is thrown. How else would you handle that?

  • Default User Avatar

    @dinglemouse: Thanks for your explanations and comments.

  • Default User Avatar

    On the contrary, this Kata is very precisely worded:

    Your task is to return the first longest string consisting of k consecutive strings taken in the array.

    • You are asked to look for consecutive strings (how many of the input strings to concatenate determined by k)
    • From those candidate concatenated strings you need to find the longest
    • And if there happen to be several candidate concatenated strings having the same longest length then you need to return the first one
  • Default User Avatar

    One can't say it simpler:

    Your task is to return the first longest string consisting of k consecutive strings taken in the array.

    In other words construct all strings constitued of k consecutive (following one another) strings of the array and return the first which has the longest length.