diff --git a/concepts/basics/introduction.md b/concepts/basics/introduction.md index e3e2cbc13b..d6ad7a668b 100644 --- a/concepts/basics/introduction.md +++ b/concepts/basics/introduction.md @@ -31,6 +31,21 @@ end my_first_calc = Calculator.new ``` +Classes can contain other classes (_inner classes_): + +``` +# Define outer class +class Calculator + + # Define inner class + class SpecialHandler + # ... + end + +# ... +end +``` + Units of functionality are encapsulated in methods - similar to _functions_ in other languages. A method can optionally be defined with positional arguments, and/or keyword arguments that are defined and called using the `:` syntax. Methods either implicitly return the result of the last evaluated statement, or can explicitly return an object via the `return` keyword. Methods are invoked using `.` syntax. ```ruby diff --git a/exercises/concept/lasagna/.docs/introduction.md b/exercises/concept/lasagna/.docs/introduction.md index af8a15fbd5..7b8fb66a09 100644 --- a/exercises/concept/lasagna/.docs/introduction.md +++ b/exercises/concept/lasagna/.docs/introduction.md @@ -47,6 +47,21 @@ end my_first_calc = Calculator.new ``` +Classes can contain other classes (_inner classes_): + +``` +# Define outer class +class Calculator + + # Define inner class + class SpecialHandler + # ... + end + +# ... +end +``` + ## Methods Units of functionality are encapsulated in methods - similar to _functions_ in other languages.