• Sign Up
    Time to claim your honor
  • Training
  • Practice
    Complete challenging Kata to earn honor and ranks. Re-train to hone technique
  • Freestyle Sparring
    Take turns remixing and refactoring others code through Kumite
  • Community
  • Leaderboards
    Achieve honor and move up the global leaderboards
  • Chat
    Join our Discord server and chat with your fellow code warriors
  • Discussions
    View our Github Discussions board to discuss general Codewars topics
  • About
  • Docs
    Learn about all of the different aspects of Codewars
  • Blog
    Read the latest news from Codewars and the community
  • Log In
  • Sign Up
seasidetesting Avatar
Name:Stephan Kämper
Clan:Unknown
Skills:software testing, ruby, oceanography, physics
Member Since:Sep 2015
Last Seen:Apr 2025
Profiles:
Following:4
Followers:15
Allies:4
View Profile Badges
  • Stats
  • Kata
  • Collections
  • Kumite
  • Social
  • Discourse
  • Conversations (205)
  • Replies
  • Authored
  • Needs Resolution
  • Custom User Avatar
    • seasidetesting
    • commented on "Playing with cubes II" ruby solution
    • 2 months ago

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
    • blarosen95
    • commented on "Playing with cubes II" ruby solution
    • 2 months ago

    I'm not sure this deserves top place for Best Practices: it couples the constructor to an instance method. As it's a constructor, the instance is yet to exist, and this sort of flaunts the purpose of OOP in Ruby.

  • Custom User Avatar
    • seasidetesting
    • commented on "Squeaky Window" ruby solution
    • 11 months ago

    Thanks! That's why we're here right? Learning something new.

  • Custom User Avatar
    • Pale-Vessel
    • commented on "Squeaky Window" ruby solution
    • 11 months ago

    Well I just learned a new method. Very clean solution!

  • Custom User Avatar
    • seasidetesting
    • commented on "The Feast of Many Beasts" ruby solution
    • 17 months ago

    That's because (in Ruby and many other languages) you can use an integer to get to the n-th charactetr in a String just as you can get the n-th element of an Array.
    You can think of a String as an ordered list of charscters (technically code points, but thats another story).

  • Custom User Avatar
    • informachikita
    • commented on "The Feast of Many Beasts" ruby solution
    • 17 months ago

    why don't we need to turn em into arrays ?

  • Custom User Avatar
    • amar47shah
    • commented on "Sort rectangles and circles by area II" ruby solution
    • 2 years ago

    This solution received the most votes for "Best Practices." But you and I agree, this monkey-patching of Array and Numeric is not a good practice, let alone "best."

  • Custom User Avatar
    • seasidetesting
    • commented on "Sort rectangles and circles by area II" ruby solution
    • 2 years ago

    I didn't claim it would be.
    However… if anywhere, I think it's acceptable especially in a narrow use case, such as a coding exercise. THe reason: Precisely because it's a narrow use case, it won't cause harm elsewhere.

    That said, using refinements would have been a cleaner way to achieve the effect, without reopening standard classes.

    In a real system that deals with geometrical objects, I'd expect that each of these objects would respond to area anyway.

  • Custom User Avatar
    • amar47shah
    • commented on "Sort rectangles and circles by area II" ruby solution
    • 2 years ago

    Numeric and Array are classes that represent structures of generic data. It is not good practice to add methods to these classes that are only meaningful in a narrow use case.

  • Custom User Avatar
    • pablisch
    • commented on "L1: Set Alarm" ruby solution
    • 2 years ago

    If you have return, it is an explicit return which can be at any point in a method, but the last expression of any method is always returned as an implicit return, so no return is ever needed for the last expression in a Ruby method.

  • Custom User Avatar
    • itsNikolay
    • commented on "Beginner Series #3 Sum of Numbers" ruby solution
    • 3 years ago

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
    • seasidetesting
    • commented on "Safen User Input Part I - htmlspecialchars" ruby solution
    • 3 years ago

    The plain reason is: Because the tests fail without this, as spaces & a few other characters match the regular expression.

    I didn't know why, when I wrote this solution (and and to think about it for a while, now that you've asked your question. A very good question!

    Now I know: The regex character class contains too many characters. The regex should be written more like this:

    /[#{REPLACEMENTS.keys.join}]/
    

    With this regular expression the method becomes even simpler, because the || match isn't needed anymore.

    That was a really good catch! Thanks for asking – and Happy hacking. 🧑‍💻

  • Custom User Avatar
    • Husoski
    • commented on "Safen User Input Part I - htmlspecialchars" ruby solution
    • 3 years ago

    Just out of curiosity, why is || match needed in the #gsub block? It seems to me that you can only match characters from REPLACEMENTS.keys and only put single-character keys into that hash.

    In any case, this gets my vote for "Best Practices".

  • Custom User Avatar
    • ejini战神
    • resolved a question on "Easy SQL: Cube Root and Natural Log" kata
    • 3 years ago

    OP solved it, closing

  • Custom User Avatar
    • ejini战神
    • resolved a question on "Coding Meetup #2 - Higher-Order Functions Series - Greet developers" kata
    • 3 years ago

    16 series ~~

  • Loading more items...
  • © 2025 Codewars
  • About
  • API
  • Blog
  • Privacy
  • Terms
  • Code of Conduct
  • Contact

Confirm

  • Cancel
  • Confirm

Collect: undefined

Loading collection data...