On 10/04/2010 03:45, Wally Kolcz wrote:
Can someone rewrite this as a switch/case? I tried, but it didn't seem
to work. Problem I am running into is the multiple conditions in the
case. Thanks!
Wally,I didn't spot anyone mentioning this (apologies if it's already
been mentioned), but all
Can someone rewrite this as a switch/case? I tried, but it didn't seem
to work. Problem I am running into is the multiple conditions in the
case. Thanks!
private function getAgeGroup(birthday:Date):int {
var age:int = getAge(birthday);
if (age = 0 age 3){ //Birth to 2
it curious but a person who are 2000 years old, with your implementation
it's group 1
run this code:
package
{
import flash.display.Sprite;
public class test extends Sprite
{
public function test()
{
trace(this.getAgeGroup(2000));
}
private function getAgeGroup(age:Number):int {
if (age = 0
This is off the top of my head in email so there may be some errors
but something like this should work
var category:Number;
switch (true){
case(age 18):
category = 0;
break;
case(age 15):
category = 6;
break;
Thanks for the try, but all ages are 18 so the first condition would
be met on all of them. I need the multiple conditions on the case to be
preserved. :)
On 4/9/2010 11:45 PM, Rob Romanek wrote:
This is off the top of my head in email so there may be some errors
but something like this
Sorry, you're right. Tired and just can't seem to get my GT and LT's
correct. :D
On 4/9/2010 11:54 PM, Wally Kolcz wrote:
Thanks for the try, but all ages are 18 so the first condition would
be met on all of them. I need the multiple conditions on the case to
be preserved. :)
On 4/9/2010
y did not understand, but i hope i help you
2010/4/9 Wally Kolcz wko...@isavepets.com
Thanks for the try, but all ages are 18 so the first condition would be
met on all of them. I need the multiple conditions on the case to be
preserved. :)
On 4/9/2010 11:45 PM, Rob Romanek wrote:
FWIW, if you are worried about performance, I would test the efficiency of
using a map, especially if age is an int and not a Number. Even if it is a
Number I might still test out a map with a Math.floor on the age.
Var agemap:Object {
0 : 1, 1: 1, 2: 1, 3: 2, 4: 2, 5: 2, 6: 3, 7: 3, 8: 3...
8 matches
Mail list logo