Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Interval>>sort: method that raises a "you can not sort an inter… #1922

Conversation

dupriezt
Copy link
Contributor

…val" error

From fogbuz issue:
Interval new sort raises an "#< was sent to nil" exception
(1 to: 5) sort raises an "you can not store into an interval" exception

The Interval class inherits the default #sort: method of SequenceableCollection, which does not work for intervals. I am not sure the concept of sorting an Interval makes sense in the general case. I suggest implementing Interval>>sort: so that it raises an explicit exception: "you can not sort an interval" akin to what Interval>>at:put: does (it raises "you can not store into an interval"). Unless someone has an idea for what "sorting an Interval" could mean.

Interval >> sort: aBlock [
"What sorting an Interval means is not clear."

self error: 'you can not sort an interval'
Copy link
Contributor

Choose a reason for hiding this comment

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

Except for the missing capital letter at the beginning of the error message and the dot at the end, this is fine for me. :-)

Copy link
Contributor Author

@dupriezt dupriezt Oct 18, 2018

Choose a reason for hiding this comment

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

I wrote it like that to be consistent with the Interval>>at:put: method:

at: anInteger put: anObject 
	"Storing into an Interval is not allowed."

	self error: 'you can not store into an interval'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But sure, why not.

…nd ends with a dot.

- Interval>>sort: method moved to sorting protocol so that it is in the same protocol as the sort: method of the superclass
@MarcusDenker
Copy link
Member

@dupriezt
Copy link
Contributor Author

@MarcusDenker @pavel-krivanek
Added a new commit to follow Pavel's suggestion of using self shouldNotImplement instead of self error:

@MarcusDenker MarcusDenker merged commit 54328a7 into pharo-project:development Nov 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants