Tag: Ruby
-
insert into linked list
The post outlines the implementation of an insert method for a Linked List. It emphasizes writing tests to ensure functionality and error handling when inserting elements. The method includes a prepend option for inserting at the start and ensures valid locations by raising errors when necessary. The process culminates in successfully adding new nodes.
-
Prepend – LinkedList
The post discusses implementing a “prepend” method for a linked list, allowing items to be added at the beginning. It begins with tests for appending items and then fails to recognize “prepend” as a method. The author details the implementation and confirms that the tests pass successfully after defining the method.
-
Linked List to String
The post discusses the implementation of a “stringify” method for a LinkedList class, allowing the conversion of node data into a string. Initial tests are conducted to ensure it functions for single and multiple data points, leading to code modifications for proper formatting and handling of empty lists.