Ruby
Learn Ruby by typing expressive, idiomatic code.
Practice Ruby's expressive style by typing it: blocks and yield, symbols, the Enumerable methods (map, select, reduce), and a taste of metaprogramming. Each snippet is idiomatic Ruby, and an AI tutor explains every line — how a block differs from a proc, why everything is an object — so the language's joy comes through as you build typing speed.
Progress0 / 695 solved · 0/50 sections
best wpm
0
avg wpm
0
accuracy
0%
runs
0
level
1
rating
1000
Run Ruby on your machine
1. Install the toolchain
brew install ruby # or: sudo apt install ruby2. Save your code as hello.rb, then compile & run
ruby hello.rbprogress by section
1Fundamentals0/16start →
2Strings In Depth0/19start →
3Values & References0/16start →
4Slices & Arrays0/16Unlock →
5Data structures0/13Unlock →
6Iterators0/20Unlock →
7Traits0/20Unlock →
Default valuesDuck typingModule mixin (include)Define to_sOperator +Comparable via <=>A conversion methodDefine ==extend for class methodsDefine inspectOperator * by scalarSorting with sort_bydup vs cloneEnumerable via eachhash and eql? as a keyOperator []Unary minus (-@)prepend wraps a methodA fallible conversioncoerce for scalar * object
8Generics0/20Unlock →
Generic swapGeneric containerDuck typingTwo independent valuesAlways dynamic dispatchGeneric over EnumerableGeneric min and maxModule as mixinStruct pairrespond_to? checksGeneric stackConvert any iterableBlock as type parameterComparable mixinData.define recordEnumerable mixinGeneric memoizerNewtype wrappermethod_missing dispatchMixed <=>
9Lifetimes0/20Unlock →
Blocks see the enclosing scopeConstants live for the programReferences keep objects aliveMethod-local scopeDropping the last referenceAliasing shares mutationA closure captures a variableensure for cleanupFile.open with a blockAn object holding a referenceReturning a closureyield to a blockBlock-local variablesA closure keeps a local aliveObserving the collectorA Method objectCounting live objectsBinding captures scopeA finalizer on collectionA weak reference
10Closures0/20Unlock →
A lambdaBlocks and yieldblock_given?Capturing the environmentdo/end vs {}Multiple parametersproc and Proc.newCallbacksAn explicit &block parameterClosures drive iteratorsCapturing in selectsort_by with a blockSymbol#to_procA stateful counterAn array of procsReturning a lambdaComposing procsCurryingSpecializing by curryinglambda vs proc
11Pattern Matching0/20Unlock →
12Error Handling0/21Unlock →
begin / rescueRaise an exceptionBind the exceptionContext in messagesCustom exception classbegin / rescue / elseensure for cleanupInspect the errorrescue modifierRescue several classesCatch every StandardErrorException with attributesEnsure a resource closesAll four clausesException hierarchyMethod-level rescueOrdered handlersRe-raiseException causeOverride the messageretry
13Option & Result0/20Unlock →
14Conversions0/15Unlock →
15Collection Conversions0/19Unlock →
16Math0/14Unlock →
17Encoding0/22Unlock →
String to bytesASCII checks and caseBase64 decodeBase64 encodeBytes to StringDigit charactersord and chrBinary, octal, hexURL-safe base64Big-endian bytesReinterpret bytesHex decodeHex encodeLittle-endian bytesParse a number in a baseROT13Percent-decodePercent-encodeBuild a query stringCaesar cipherPack and unpack fieldsXOR cipher
18Random0/20Unlock →
Random floatRandom integerCoin flipPick an elementRandom in a rangeSeeded generatorRandom alphanumeric stringWeighted true/falseRandom byte arrayRandom symbolPassword generatorReproducible sequencesSample without replacementSecure hex tokenRandom UUIDShuffleRoll many diceSecure random bytesWeighted choiceNormal distribution
19Data I/O0/18Unlock →
Parse CSV rowsGenerate JSONParse JSONTab-separated valuesBuild a CSV stringSelect one columnCSV with headersCSV to a number matrixPretty-print JSONWhitespace matrixRead a file wholeSkip blanks and commentsPrint an aligned tableWrite a matrix as textStream linesParse key=value configRound-trip write and readDrop unparseable rows
20Linear Algebra0/21Unlock →
21Text Processing0/16Unlock →
22Date & Time0/12Unlock →
23Memory0/12Unlock →
24Modules0/20Unlock →
A module as a namespaceAlias a moduleConstants in a moduleinclude a moduleMix in several modulesNested modulesPublic vs privateA class in a moduleConstants as an enumextend a moduleThe require conceptReach a sibling module:: absolute scopeA small utility moduleThe Comparable mixinEncapsulationFlatten a deep pathmodule_functionprivate_constantsuper through a module
25Macros0/20Unlock →
Print to standard errorA raise-based assertNotImplementedError placeholdertapdefine_methoddefine_method with an argumentformat specifiersVariadic argumentsDefine methods in a loopinstance_variable_get / setMethods as objectsPattern matchingsend / public_sendSingleton methodsBuild text with StringIOClass.newconst_get / const_setDefine readers from a hashclass_eval / instance_evalmethod_missing
26Testing0/20Unlock →
assert with a messageA unit testTesting a truth tableMultiple testsrefute_equalTesting string outputAsserting on an arrayComments + a testTesting an error caseA hand-rolled assertA test helperTesting a methodTesting nil resultsTesting a raise pathassert_raisesSkipping a testComparing floatsTesting a private methodassert_raises with a messageTable-driven tests
27Algorithms0/8Unlock →
28Sorting Algorithms0/12Unlock →
29Expression Parsing0/6Unlock →
30Idioms0/9Unlock →
31OOP & Traits0/8Unlock →
32Trait Objects0/14Unlock →
A method taking any speakerAn array of mixed objectsReturn one of several typesCollect a mark from eachTwo names, one objectDispatch by classAn array of lambdasShared default methodA pipeline of callablesrespond_to? capability checkTotal over mixed shapesComparable across typesA handler registryA module including a module
33Design Patterns0/14Unlock →
35File I/O0/6Unlock →
36Filesystem0/18Unlock →
Does a path exist?List a directoryCopy a fileFiles vs directoriesBuild a pathCreate nested directoriesRename or moveChange the extensionFile metadataPath componentsRemove files and treesSorted listingA scratch temp dirAbsolute pathTotal size of a treeFilter by extensionLast modified timeWalk the tree
37Networking0/16Unlock →
38Concurrency0/7Unlock →
39Unsafe & FFI0/14Unlock →
40Commands0/14Unlock →
41Array0/10Unlock →
43String0/10Unlock →
45Interval0/5Unlock →
46Linked List0/6Unlock →
47Tree0/14Unlock →
Maximum Depth of Binary TreeInvert Binary TreeSame TreeLowest Common Ancestor of a BSTBinary Tree Level Order TraversalSubtree of Another TreeImplement Trie (Prefix Tree)Kth Smallest Element in a BSTValidate Binary Search TreeAdd and Search WordConstruct Binary Tree from Preorder and InorderBinary Tree Maximum Path SumSerialize and Deserialize Binary TreeWord Search II