Skip to content

Conversation

@balbesina
Copy link

Several List improvements.

  • allow to pass range to List#elements.
  • add List#size and List#first.
  • fix List#last to return typed.
Mikhail Varabyou added 2 commits March 31, 2024 11:09
allow to pass range to List#elements. fix List#last to return typed.
@balbesina
Copy link
Author

any chance someone can review it?


def elements
strings_to_types(lrange(0, -1) || [], typed)
def elements(start = 0, stop = -1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than give slicing arguments to #elements, would introduce #slice and have #elements call it.

@list.append [ 1.day.from_now.midnight.in_time_zone("Pacific Time (US & Canada)"), 2.days.from_now.midnight.in_time_zone("UTC") ]
assert_equal [ 1.day.from_now.midnight, 2.days.from_now.midnight ], @list.elements
test "size" do
@list.clear
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would assert_equal 0, @list.size here rather than having a separate test for size after removal.

@balbesina balbesina requested a review from jeremy April 19, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants