bobbyno / ruby_drills Goto Github PK
View Code? Open in Web Editor NEWA deliberate practice framework to help you learn Ruby
License: Apache License 2.0
A deliberate practice framework to help you learn Ruby
License: Apache License 2.0
@value = "bobcat"
Remove 'bob' from this string in order to return a much tamer version.
Use a non-destructive method to remove 'bob' from this string and return "cat":
>> @value.sub("bob", "")
Not yet...
I would expect any of these (and more) to work:
@value.sub("bob", "")
@value.gsub("bob", "")
@value.tr("bo", "")
@value[3..-1]
@value.gsub(/[bo]/, '')
Enumerable
methods behave slightly differently on Array
and Hash
. I think the Enumerable
drills that exist (which are all based on Array
) should move to Array
and we should add separate drills for the same methods on Hash
. WDYT?
My .inputrc settings make the REPL blow up when I try using vim keybindings to navigate. I know I shouldn't do this, but my fingers type it before my brain is on board.
I don't expect this to be fixed, I just wanted to give you a heads up that the data my sessions are providing are not going to be very helpful to your statistical analysis. (feel free to close this as soon as you've seen it).
RSpec?
Aruba?
One of the instructions for a String
drill said:
Take this string and turn it into a symbol. The output should be
:mouse:
Knowing beginners, there is reason to believe that they might expect the output to be :mouse:
rather than :mouse
.
Would it be worth adding backticks around code snippets to make it clear what is code vs what is English text?
UPDATE: I had to put backticks in the quoted text, because GitHub turns :mouse:
into ๐ญ.
It seems like comparison of an input
and a reference
is done the wrong way, since comparing hashes - unordered collections - as strings simply won't work as expected.
Consider the reference solution from the merge
drill:
"@matched_animals.merge(@mismatched_animals) { |key, v1, v2| v1 }"
Passed through to Pry.run_command
, it produces the following result:
"=> {\"cat\"=>\"meow\", \"dog\"=>\"woof\", \"frog\"=>\"ribbit\", \"pig\"=>\"oink\"}"
My proposed solution
"@mismatched_animals.merge(@matched_animals)"
gives the following result:
"=> {\"cat\"=>\"meow\", \"dog\"=>\"woof\", \"pig\"=>\"oink\", \"frog\"=>\"ribbit\"}"
Hence comparison of the two strings results in false
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.