tatara

Add Type to Ruby!

This project is maintained by S-H-GAMELINKS

Tatara::IntFloatMap

About

Tatara::IntFloatMap is Map class like static type programming lang.

Tatara::IntFloatMap used by Integer key, and Float value. But, you can use Float for key & value.

@i = Tatara::IntFloatMap.new
@i[0] = 42
# => Key: 0, Value: 42.0
@i[10.0] = 8.4
# => Key: 10, Value: 8.4

But, can not set String.

@i = Tatara::IntFloatMap.new
@i[0] = "42"
# => Error!

Methods

Tatara::IntFloatMap#new

Create new Tatara::IntFloatMap instance.

@i = Tatara::IntFloatMap.new

Tatara::IntFloatMap#[]

Access by key.

@i = Tatara::IntFloatMap.new
@i[0] = 4.2
puts @i[0]
# => 4.2

Tatara::IntFloatMap#[]=

Set value by key.

@i = Tatara::IntFloatMap.new
@i[0] = 4.2
# => Set value is 4.2

Tatara::IntFloatMap#insert

Set key & value.

@s = Tatara::IntFloatMap.new
@s.insert(0, 4.2)
# => Set value is 4.2.