[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] 3 == "b"






here's a problem in the sc language:

3 == "b"

ERROR:
Primitive '_ArrayAdd' failed.

Wrong type.
RECEIVER:
Instance of String {    (08A4E860, gc=00, fmt=08, flg=00, set=00)
}
CALL STACK:
	Object::primitiveFailed
		arg this = ""
	ArrayedCollection::add
		arg this = ""
		arg item = false
	< FunctionDef in Method Collection::collectAs >
		arg elem = $b
		arg i = 0
	ArrayedCollection::do
		arg this = "b"
		arg function = <instance of Function>
		var size = nil
		var i = 0
	Collection::collectAs
		arg this = "b"
		arg function = <instance of Function>
		arg class = class String
		var i = nil
		var res = ""
	Collection::collect
		arg this = "b"
		arg function = <instance of Function>
	SequenceableCollection::performBinaryOpOnSimpleNumber
		arg this = "b"
		arg aSelector = '=='
		arg aNumber = 3
	SimpleNumber::==
		arg this = 3
		arg aNumber = "b"
...


for a normal (assuming numerical) collection, this would be appropriate,
but for a string, it isn't.

	// no sense doing collect as per collection
	performBinaryOpOnSimpleNumber { arg aSelector, aNumber;
		^this.perform(aSelector, aNumber)
	}
	performBinaryOpOnComplex { arg aSelector, aComplex;
		^this.perform(aSelector, aComplex)
	}
	performBinaryOpOnInfinitum { arg aSelector, aNumber;
		^this.perform(aSelector, aNumber)
	}


because
"b" == 3 works

and
"b" * 4  fails as it should



-felix