Loto6のような1から48までの数を6個作るスクリプト

しばりがなければどう書くか、#includes: をどう代替えするか、#includes: を必要としない方針だとどうなるか、とかと考えると単純な問題ながら楽しめそうです。ざっと思いついたところで。

"すなおな手続き的バージョン"
collection
collection := OrderedCollection new. [collection size < 6] whileTrue: [ | rand | rand := 48 atRandom. (collection includes: rand) not ifTrue: [collection add: rand]]. ^collection
"んなもんコレクションが自分で判断しろよバージョン"
collection
collection := OrderedCollection new. [collection size < 6] whileTrue: [collection addIfNotPresent: 48 atRandom]. ^collection
"頼む相手を選ぼうバージョン"
collection
collection := Set new. [collection size < 6] whileTrue: [collection add: 48 atRandom]. ^collection
"実世界の状況反映バージョン"
source collection
collection := OrderedCollection new. source := (1 to: 48) asOrderedCollection. 6 timesRepeat: [collection add: (source remove: source atRandom)]. ^collection
"Journal InTime さん版1を参考にした実世界の状況反映バージョン2"
source
source := (1 to: 48) asOrderedCollection. ^(1 to: 6) collect: [: void | source remove: source atRandom]
"駄目だったらやり直せばいいじゃんバージョン Set 編"
array
[(array := (1 to: 6) collect: [: void | 48 atRandom]) asSet size = 6] whileFalse. ^array
"駄目だったらやり直せばいいじゃんバージョン Bag 編"
array
[(array := (1 to: 6) collect: [: void | 48 atRandom]) asBag sortedCounts first key > 1] whileTrue. ^array
"なんとなくテンポラリ変数宣言したくない気分…バージョン"
^Array streamContents: [: stream |
  [stream size < 6] whileTrue: [
    48 atRandom in: [: rand |
      (stream contents includes: rand) not ifTrue: [stream nextPut: rand]]]]
"なんでかテンポラリ変数モドキすら受け付けない気分…バージョン"
^Array streamContents: [: stream |
  [stream size < 6] whileTrue: [
    stream nextPut: 48 atRandom.
    (stream contents allButLast includes: stream last) ifTrue: [
      stream position: stream position - 1]]]

追記
なるほど SequenceableCollection >> #shuffled ! これが最もシンプルでわかりやすそうですね。

"これもある意味、実世界の状況反映バージョン"
^(1 to: 48) asArray shuffled first: 6

ついでに

"Journal InTime さんが例として挙げておられる Ruby 版その1"
candidates
candidates := (1 to: 48) asOrderedCollection. ^(1 to: 6) collect: [: void | candidates removeAt: candidates size atRandom]
"Journal InTime さんが例として挙げておられる Ruby 版その2に特異クラスもどきでチャレンジ編"
collection randomStream randomStreamClass
randomStream := Object new assureUniClass. randomStreamClass := randomStream class. randomStreamClass compile: 'do: aBlock [aBlock value: 48 atRandom] repeat' classified: 'enumeration'. randomStreamClass superclass: Collection. collection := OrderedCollection new. 6 timesRepeat: [ collection add: (randomStream detect: [: each | (collection includes: each) not])]. randomStream := nil. randomStreamClass removeFromSystem. ^collection
"Journal InTime さんが例として挙げておられる Ruby 版その2にブロックでチャレンジ編"
randomStream collection
randomStream := [: detectBlock | | rand | [detectBlock value: (rand := 48 atRandom)] whileFalse. rand]. collection := OrderedCollection new. 6 timesRepeat: [ collection add: (randomStream value: [: each | (collection includes: each) not])]. ^collection