# Conventions in ruby and the principle of least surprise

**URL:** <https://www.ruby-forum.com/t/conventions-in-ruby-and-the-principle-of-least-surprise/158706>\
**Category:** Ruby\
**Created:** [January 27, 2009, 3:14am UTC](https://www.ruby-forum.com/t/conventions-in-ruby-and-the-principle-of-least-surprise/158706 "2009-01-27T03:14:00Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![einarmagnus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3d9bf3/32.png) [@einarmagnus](https://www.ruby-forum.com/u/einarmagnus)\
**Post date:** [January 27, 2009, 3:50am UTC](https://www.ruby-forum.com/t/conventions-in-ruby-and-the-principle-of-least-surprise/158706/2 "2009-01-27T03:50:12Z")

</div>

Hi,

In message “Re: Conventions in ruby and the principle of least surprise”  
on Tue, 27 Jan 2009 11:11:55 +0900, Einar Boson  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|do…end vs. {}

|I find that rather annoying but I guess it’s to be able to write things  
|like  
|  
|save\_block [“name1\_long”, “name2\_long”, “short”].find {|n| n.size \<=  
|5}.to\_sym do  
| puts “hello!”  
|end

Correct.

|Anyways. More serious, in my oppinion, is the fact that Array#insert and  
|String#insert are destructive without having an exclamation mark. Why is  
|that? I really do not expect them to change their owner.

|seriously, wtf? Why not `insert` and `insert!` that behave as expected?

The bang (!) does not mean “destructive” nor lack of it mean non  
destructive either. The bang sign means “the bang version is more  
dangerous than its non bang counterpart; handle with care”. Since  
Ruby has a lot of “destructive” methods, if bang signs follow your  
opinion, every Ruby program would be full of bangs, thus ugly.

```
          matz.

```

---

_[View the full topic](https://www.ruby-forum.com/t/conventions-in-ruby-and-the-principle-of-least-surprise/158706)._
