#bool in (dart)

20 messages · Page 1 of 1 (latest)

slow meadowBOT
#

@indigo widget

File Attachments Not Allowed

For safety reasons we do not allow files with certain file extensions.

letingoaddict Said
void main(){
  List magicSquare = [
    [2, 7, 6],
    [9, 5, 1],
    [4, 3, 8],
];

List checkingMagicFuncs = [
  coloumnChecker(magicSquare),
  rowChecker(magicSquare),
  rightDiagonalChecker(magicSquare),
  leftDiagonalChecker(magicSquare),
  ];


functionChecker(checkingMagicFuncs);

}

basically all i need is someone to review my code :
also im thinking of creating one function named diagonalChecker and take either "left" or "right" as arg instead of creating two functions rightDiagonalChecker and leftDiagonalChecker to reduce redundancy maybe?

Code Formatting

You can share your code using triple backticks like this:
```
YOUR CODE
```

Large Portions of Code

For longer scripts use Hastebin or GitHub Gists and share the link here

Ignored these files due to them having disallowed file extensions
  • magic_square.dart
indigo widget
indigo widget
haughty portal
indigo widget
haughty portal
#

I can't see that one since it's deleted

indigo widget
#

basically all i need is
someone to review my code: also im thinking of
creating one function
named diagonalChecker and take either "left" or "right" as arg instead of creating two functions rightDiagonal Checker and
leftDiagonal Checker to
reduce redundancy maybe?

indigo widget
haughty portal
#

Will continue the review after lunch

indigo widget
#

Sure enjoy your meal

haughty portal
#

Comments:

  • Line 25 and line 32, why are you comparing a boolean to true or false?
  • The loop in line 24 could be a bit more concise, bool functionIsTrue = functions.any((x) => x);
  • The entire function in line 41 could probably be refactored to listOfNumbers.fold(0, (p, c) => p + c);
  • rowChecker could be simplified to return magicSquare.all((row) => sum(row) == 15);, same thing kind of applies to the coloumnChecker (also it's spelled column)
indigo widget
#

respect++

indigo widget
#
final numbers = <int>[1, 2, 3, 5, 6, 7];
var result = numbers.any((element) => element >= 5); // true;
result = numbers.any((element) => element >= 10); // false;

What does this code do like from my understanding all it do is like checks if any element is 5 it returns true
but what i dont understand is what does >= mean is it greater than or equal to?

#

oh i think i got it


  bool a = true, b = false, c = true;
  List bools = [a, b, c];


  print(bools.any((element) => b));

it js checks whether the given element is in the list or not

#

nvm then

#

but theres still gonna be more questions i hope i can do them on my own if not then not rob

indigo widget
#

i dont get it

#

what does >= mean