Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Let's Get Creative with Arguments by Polly Schandorf\n\nWould you like better error messages? Or methods that are clearer to the caller. How about more flexibility ? Most of us have a preference for parameters, but sometimes there are better options in certain circumstances. We’ll look at keyword arguments, option hashes, splats and destructuring. \n\nIn her previous life, Polly was a teacher of elementary through high school students. After being introduced to coding using a Rasberry Pi in a teacher workshop - she was hooked, and never looked back. She is totally fascinated with fermented foods and makes her own Kombucha, Kefir and Red Wine Vinegar.
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In "Let's Get Creative with Arguments," Polly Schandorf discusses the various ways to handle method arguments in Ruby, focusing on enhancing clarity and flexibility in programming. Drawing from her experience as a developer, Polly outlines different techniques, each with its distinct advantages and disadvantages, and emphasizes the importance of selecting appropriate argument types based on specific situations. Key points discussed include: - **Positional Arguments:** Typically simple and commonly used, these rely on the order of parameters but can lead to confusion and poor error messages when the order is mixed up. Polly illustrates this through an example involving a function that describes her cat, highlighting how errors occur when arguments are not passed in the expected order. - **Optional Hashes:** These allow flexibility by accepting key-value pairs, making it possible to call functions with various parameters while also assigning default values. However, hidden details about parameter requirements can complicate usage. - **Destructuring:** Offers efficient extraction of multiple values from hashes, leading to cleaner and more readable code while noting that over-reliance on this technique may lead to misuse. - **Keyword Arguments:** Introduced in Ruby 3.0, this method enhances clarity and provides explicit error messages compared to positional arguments. Each argument must be named, improving readability, although too many keyword arguments may indicate a need for refactoring into objects. - **Splat Syntax:** This allows handling a variable number of arguments gracefully, supporting both positional and keyword arguments in a streamlined fashion. Polly provides a scenario with splats, examining how they can succinctly process data for practical applications such as a family adopting shelter cats. Polly concludes with a call to engage in community events like Ruby for Good, emphasizing the importance of collaboration within the Ruby community and the opportunities available from participating in such gatherings. She encourages attendees to seek connections that could lead to professional growth while reflecting on the camaraderie developed during these events.
Suggest modifications
Cancel