ruby-kickstart | interactive guide to learning the Ruby programming language | Learning library
kandi X-RAY | ruby-kickstart Summary
kandi X-RAY | ruby-kickstart Summary
An interactive guide to learning the Ruby programming language.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- returns a new array of the current algorithm
ruby-kickstart Key Features
ruby-kickstart Examples and Code Snippets
Community Discussions
Trending Discussions on ruby-kickstart
QUESTION
I'm trying to pass several parameters of class Integer
to one of two methods—the pick is determined by the final parameter passed to the initial method.
The problem is described in full here, but in short, my methods should correctly count the no. of chains of 2+ identical digits when multiple digits are passed in with a final param of :problem => :count_clumps
.
i.e. problem_14(1, 2, 2, 2, 2, 3, 4, 4, :problem => :count_clumps)
should return 2
, as it contains 2 chains of 2+ identical digits.
I'm failing an rspec test for the following:
problem_14(1, 2, 2, 3, 4, 4, :problem => :count_clumps)
My methods should return 2
, but they return 0
.
I think the problem is with whatever problem_14
is passing to count_clumps
. count_clumps
passes rspec tests when tested directly, but returns the wrong result when invoked via problem_14
.
ANSWER
Answered 2017-Mar-25 at 23:27In ruby, the splat (*) operator takes all parameters and turns them into an array. So when you do this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ruby-kickstart
On a UNIX-like operating system, using your system’s package manager is easiest. However, the packaged Ruby version may not be the newest one. There is also an installer for Windows. Managers help you to switch between multiple Ruby versions on your system. Installers can be used to install a specific or multiple Ruby versions. Please refer ruby-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page