Skip to content

Instantly share code, notes, and snippets.

@rrreeeyyy
Last active December 24, 2015 07:49
Show Gist options
  • Save rrreeeyyy/6766821 to your computer and use it in GitHub Desktop.
Save rrreeeyyy/6766821 to your computer and use it in GitHub Desktop.
配列が循環参照するか検出するメソッド Array#is_cycle?
class Array
def is_cycle?
!!(self.inspect =~ /[^"]\[\.\.\.\][^"]/)
end
end
@rrreeeyyy
Copy link
Author

↑ "[...]" という文字列を含む循環参照配列に対して無力だったので更に直した

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment