Compiling tictactoe

Good day to all,

I have made some improvements with my tictactoe, and would like to test if it works. When trying to compile, I get some errors that I don`t understand

main.cpp:205:1: error: stray '\302' in program

int w = 0;

^

main.cpp:205:1: error: stray '\240' in program

main.cpp: In function 'bool is_win(board)':

main.cpp:105:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

for (int i = 0; i < sizeof(wins) / sizeof(wins[0]); ++i) {

^

main.cpp: In function 'int Search(int, board)':

main.cpp:204:9: error: declaration of 'board b' shadows a parameter

board b = combined();

^

main.cpp:219:21: warning: left operand of comma operator has no effect [-Wunused-value]

bestMove = (x,y);


Code is given below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235

#include <iostream>
#include <bitset>
#include <cstdlib>
#include <vector>
#include <limits>

using std::cin;
using std::cout;
using std::ostream;
using std::endl;
using std::bitset;

const size_t N = 3;
typedef bitset <N*N> board;


const board wins[] = {
    board(0b111000000), board(0b000111000), board(0b000000111),    // rows
    board(0b100100100), board(0b010010010), board(0b001001001),	// cols
    board(0b100010001), board(0b001010100)	// diagonals
};

board noughts;			// bit board for first player
board crosses;			// bit board for second player


const char NOUGHT = 'O';
const char CROSS = 'X';

int Search(int depth, board b);
board combined();
ostream & print_board(ostream & stm = cout, board b = combined());

// This indicates the current player. Computer plays noughts.
bool curr_move_noughts = true;

board
combined()
{
    return noughts | crosses;
}				// combined bit board for both players

bool
valid(size_t row, size_t col)
{
    return row < N && col < N;
}

size_t
pos(size_t row, size_t col)
{
    return row * N + col;
}				// map row, col to bit position

bool
occupied(size_t row, size_t col)
{
    return valid(row, col) && combined()[pos(row, col)];
}

bool
free(size_t row, size_t col)
{
    return valid(row, col) && !occupied(row, col);
}

size_t last_move_row = -1, last_move_col = -1 ;

void make_move( size_t row, size_t col, board & b )
{
    if (free(row, col))
    {
	b[pos(row, col)] = true;
        last_move_row = row ;
        last_move_col = col ;
    } 
}

void unMake(board & b )
{
	
    
    if (valid(last_move_row, last_move_col))// if valid last_move_row, last_move_col
    {
    int row= -1;
    int col= -1;
    b[pos(row, col)] = true;
    last_move_row = -1 ;
    last_move_col = -1 ; 
    }
}

void
make_move(size_t row, size_t col)
{
    if (curr_move_noughts)
	make_move(row, col, noughts);
    else
	make_move(row, col, crosses);
}

bool
is_win(board b)
{
    for (int i = 0; i < sizeof(wins) / sizeof(wins[0]); ++i) {
	if ((wins[i] & b) == wins[i])
	    return true;
    }
    return false;
}

bool
is_win()
{
    return is_win(curr_move_noughts ? noughts : crosses);
}

// is the board full?
bool is_full(board b)
{
    static board fullboard(0b111111111);
    return b == fullboard;
}

bool is_full()
{
    return is_full(curr_move_noughts ? noughts : crosses);
}

  
int Evaluate(board b)

{
    if (curr_move_noughts)                                     // Max player
        return Evaluate(b);
    else
        return -Evaluate(b);
}
 




void
play()
{

    int row = -1;		// For player input
    int col = -1;

    for (int turns = 0; turns < 9; ++turns) {
	curr_move_noughts = !curr_move_noughts;

	if (curr_move_noughts) {
	   board b = combined();	
	   int z = 0;
           z= Search(5,b);		// computer plays noughts
	} 
	 
         else {
	    cout << "Choose a move..." << endl;
	    cout << "Enter row and col : ";
	    cin >> row >> col;
	 
	    if (!valid(row,col)) {
		cout << "Illegal move!  Try again...\n" << endl;
	    } else {
		make_move(row, col);
	    }
	}
	print_board();
	if (is_win()) {
	    cout << "Player " << (curr_move_noughts ? NOUGHT : CROSS) << " has won!" << endl; exit(0);
	} else if (is_full()) {
	    cout << "Game ended in a tie!" << endl;
	}
    }
}



ostream & print_board(ostream & stm, board b)
{
    stm << "------\n";
    for (std::size_t i = 0; i < N; ++i) {
	for (std::size_t j = 0; j < N; ++j) {
	    const size_t
		k = pos(i, j);
	    if (b[k])
		stm << (noughts[k] ? NOUGHT : CROSS) << ' ';
	    else
		stm << ". ";
	}
	stm << '\n';
    }
    return stm << "------\n";
}

int Search(int depth, board b)
{
  
  board b = combined();
  int w = 0;
  w = Evaluate(b);
  int score;
  int x,y;
  int bestScore = std::numeric_limits<int>::min(); 
  bool bestMove = false;
  if(depth == 0) return w; 
  for (int turns = 0; turns < 9; ++turns) {                 // loop over turns
    while (occupied(x,y));
    make_move(x, y);              
    score = -Search(depth-1,b);       // recursion 
    unMake(b);
    if(score > bestScore) {         
      bestScore = score;
      bestMove = (x,y);
    }
  }
  return  bestScore; 
  return  bestMove;

 }
 

			

int
main()
{
    play();
    return 0;
}



Hope someone can help.
Last edited on
These aren't the errors that I get (although I am compiling on windows to be fair). I get issues with the format of bit pattern numbers like '0b111000000'. i think you need to pass in bit patterns as strings. See:
http://www.cplusplus.com/reference/bitset/bitset/bitset/


Some observations:

1
2
  return  bestScore; 
  return  bestMove;

you can't return 2 things like this. 'return bestMove' will never get reached.

Your recursive functions e.g.
1
2
3
4
5
6
7
8
void
make_move(size_t row, size_t col)
{
	if (curr_move_noughts)
		make_move(row, col, noughts);
	else
		make_move(row, col, crosses);
}

I think these must surely cause infinite loops? Unless I'm missing something.

Your Search method:
1
2
3
4
int Search(int depth, board b)
{

	board b = combined();


You pass in a board ('b'), and then create another board variable called 'b'. that's what your error:

main.cpp:204:9: error: declaration of 'board b' shadows a parameter

board b = combined();

is about.

also, what's this supposed to do:
bestMove = (x, y);
?
Last edited on
"You can't return 2 things like this. 'return bestMove' will never get reached."

Can you please be more specific?

Perhaps I could write like this:

return ( bestScore, bestMove );

My goal would be to limit the number of arguments taken by the Search function to the maximum.





if you want to return more than one thing from a function you either have to pass the variables in by reference or create a small class that holds your 2 items and return one of those.

This:
return ( bestScore, bestMove );
is weird.
Last edited on
Yes, I can use references.

I need to solve first bestMove = (x, y); though.

Probably it`s not working?

Think about bestMove = MOVE. What is MOVE?
do you just want the highest value? In that case use something like:

 
bestMove = std::max(x,y);



Think about bestMove = MOVE. What is MOVE?

i'm not sure why you're asking us what your code does :)
My answer was to

"also, what's this supposed to do:
bestMove = (x, y);
? "

"do you just want the highest value? "

Nodes are evaluated by actually changing the board state, doing the evaluation and then undoing the hypothetical move again.

Think about

1
2
3
4
5
6
7
8
9
10

for(EVERY move) {                 // loop over moves
    MakeMove(move);               
    score = -Search(depth-1);       // recursion 
    UnMake();
    if(score > bestScore) {         
      bestScore = score;
      bestMove = move;
    }



That`s not C++, but i doesn`t have to be. "move" stands in our case for (x,y), that is, the move.
Last edited on
I have made progress :D

Here is my updated code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262



#include <iostream>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <limits>

using std::cin;
using std::cout;
using std::ostream;
using std::endl;
using std::bitset;
using std::tuple;

const size_t N = 3;
typedef bitset <N*N> board;


const board wins[] = {
    board(0b111000000), board(0b000111000), board(0b000000111),    // rows
    board(0b100100100), board(0b010010010), board(0b001001001),	// cols
    board(0b100010001), board(0b001010100)	// diagonals
};

board noughts;			// bit board for first player
board crosses;			// bit board for second player


const char NOUGHT = 'O';
const char CROSS = 'X';

int Search(int depth, board b);
board combined();
ostream & print_board(ostream & stm = cout, board b = combined());

// This indicates the current player. Computer plays noughts.
bool curr_move_noughts = true;

board
combined()
{
    return noughts | crosses;
}				// combined bit board for both players

bool
valid(size_t row, size_t col)
{
    return row < N && col < N;
}

size_t
pos(size_t row, size_t col)
{
    return row * N + col;
}				// map row, col to bit position

bool
occupied(size_t row, size_t col)
{
    return valid(row, col) && combined()[pos(row, col)];
}

bool
free(size_t row, size_t col)
{
    return valid(row, col) && !occupied(row, col);
}

size_t last_move_row = -1, last_move_col = -1 ;

void make_move( size_t row, size_t col, board & b )
{
    if (free(row, col))
    {
	b[pos(row, col)] = true;
        last_move_row = row ;
        last_move_col = col ;
    } 
}

void unMake(board & b )
{
	
    
    if (valid(last_move_row, last_move_col))// if valid last_move_row, last_move_col
    {
    int row= -1;
    int col= -1;
    b[pos(row, col)] = true;
    last_move_row = -1 ;
    last_move_col = -1 ; 
    }
}

void
make_move(size_t row, size_t col)
{
    if (curr_move_noughts)
	make_move(row, col, noughts);
    else
	make_move(row, col, crosses);
}

bool
is_win(board b)
{
    for (int i = 0; i < sizeof(wins) / sizeof(wins[0]); ++i) {
	if ((wins[i] & b) == wins[i])
	    return true;
    }
    return false;
}

bool
is_win()
{
    return is_win(curr_move_noughts ? noughts : crosses);
}

// is the board full?
bool is_full(board b)
{
    static board fullboard(0b111111111);
    return b == fullboard;
}

bool is_full()
{
    return is_full(curr_move_noughts ? noughts : crosses);
    
}


static int evaluate(board b)
{
    

    if (is_win (curr_move_noughts))
    {
        return 1;
    }
    else if (is_win (crosses))
    {
        return -1;
    }
    else
    {
        return 0;
    }
}

  
int evaluateNegamax(board b)

{
    if (curr_move_noughts)                                     // Max player
        return evaluate(b);
    else
        return -evaluate(b);
}
 




void
play()
{

    int row = -1;		// For player input
    int col = -1;

    for (int turns = 0; turns < 9; ++turns) {
	curr_move_noughts = !curr_move_noughts;

	if (curr_move_noughts) {
	   board b = combined();	
	   int z = 0;
           z= Search(5,b);		// computer plays noughts
	} 
	 
         else {
	    cout << "Choose a move..." << endl;
	    cout << "Enter row and col : ";
	    cin >> row >> col;
	    // dmh - note that valid rows/col are 0-2, not 1-3. If you
	    // want the user to enter 1-3 then decrement the value
	    // they enter right after they enter it
	    if (!valid(row,col)) {
		cout << "Illegal move!  Try again...\n" << endl;
	    } else {
		make_move(row, col);
	    }
	}
	print_board();
	if (is_win()) {
	    cout << "Player " << (curr_move_noughts ? NOUGHT : CROSS) << " has won!" << endl; exit(0);
	} else if (is_full()) {
	    cout << "Game ended in a tie!" << endl;
	}
    }
}



ostream & print_board(ostream & stm, board b)
{
    stm << "------\n";
    for (std::size_t i = 0; i < N; ++i) {
	for (std::size_t j = 0; j < N; ++j) {
	    const size_t
		k = pos(i, j);
	    if (b[k])
		stm << (noughts[k] ? NOUGHT : CROSS) << ' ';
	    else
		stm << ". ";
	}
	stm << '\n';
    }
    return stm << "------\n";
}



tuple<int, move> Search(int depth, board b)
{
  board combined(); =b;
  int w = 0;
  w = evaluateNegamax(b);
  int move;
  int bestScore = std::numeric_limits<int>::min(); 
  bool bestMove = false;
  if(depth == 0) return w;
  int x=0, int y=0;
  for (int x = 0; x < 9; ++x) {
  for (int y = 0; y < 9; ++y) {
    while (!occupied(x,y));
    make_move(move);              
    score = -Search(depth-1,b);       // recursion 
    unMake(b);
    if(score > bestScore) {         
      bestScore = score;
      bestMove = move;
    }
   }
  }

   // return the best move
   return std::make_tuple(bestScore, bestMove);
}



int
main()
{
    play();
    return 0;
}



Getting still some errors:

main.cpp: In function 'void play()':

main.cpp:177:9: warning: variable 'z' set but not used [-Wunused-but-set-variable]

int z = 0;

^

main.cpp: At global scope:

main.cpp:224:12: error: 'move' was not declared in this scope

tuple<int, move> Search(int depth, board b)

^

main.cpp:224:12: note: suggested alternative:

In file included from /usr/local/include/c++/4.9.2/bits/char_traits.h:39:0,

from /usr/local/include/c++/4.9.2/ios:40,

from /usr/local/include/c++/4.9.2/ostream:38,

from /usr/local/include/c++/4.9.2/iostream:39,

from main.cpp:1:

/usr/local/include/c++/4.9.2/bits/stl_algobase.h:489:5: note: 'std::move'

move(_II __first, _II __last, _OI __result)

^

main.cpp:224:16: error: template argument 2 is invalid

tuple<int, move> Search(int depth, board b)

^

main.cpp: In function 'int Search(int, board)':

main.cpp:226:21: error: expected primary-expression before '=' token

board combined(); =b;

^

main.cpp:233:12: error: expected unqualified-id before 'int'

int x=0, int y=0;

^

main.cpp:237:19: error: no matching function for call to 'make_move(int&)'

make_move(move);

^

main.cpp:237:19: note: candidates are:

main.cpp:70:6: note: void make_move(size_t, size_t, board&)

void make_move( size_t row, size_t col, board & b )

^

main.cpp:70:6: note: candidate expects 3 arguments, 1 provided

main.cpp:95:1: note: void make_move(size_t, size_t)

make_move(size_t row, size_t col)

^

main.cpp:95:1: note: candidate expects 2 arguments, 1 provided

main.cpp:238:5: error: 'score' was not declared in this scope

score = -Search(depth-1,b); // recursion

^

main.cpp:248:46: error: cannot convert 'std::tuple<int, bool>' to 'int' in return

return std::make_tuple(bestScore, bestMove);

^

main.cpp:233:7: warning: unused variable 'x' [-Wunused-variable]

int x=0, int y=0;

^

main.cpp:249:1: warning: control reaches end of non-void function [-Wreturn-type]

}

^
Last edited on
some of those errors are self-explanatory.
e.g. line 227
 
tuple<int, move> Search(int depth, board b)

You don't have a class or struct called 'move' so that's an error. Did you mean this instead:

 
tuple<int, bool> Search(int depth, board b)

?


line 229:
board combined(); =b;
this makes no sense at all.

int x=0, int y=0;
change the comma to be a semi-colon.

etc etc
I changed the code, and is now like follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285

#include <iostream>
#include <bitset>
#include <cstdlib>
#include <limits>
#define curr_move_noughts 1
#define crosses -1

int side==curr_move_noughts ? 1 : -1

using std::cin;
using std::cout;
using std::ostream;
using std::endl;
using std::bitset;


const size_t N = 3;
typedef bitset <N*N> board;


const board wins[] = {
    board(0b111000000), board(0b000111000), board(0b000000111),    // rows
    board(0b100100100), board(0b010010010), board(0b001001001),	// cols
    board(0b100010001), board(0b001010100)	// diagonals
};

board noughts;			// bit board for first player
board crosses;			// bit board for second player


const char NOUGHT = 'O';
const char CROSS = 'X';

int Search(int depth, board b);
board combined();
ostream & print_board(ostream & stm = cout, board b = combined());

// This indicates the current player. Computer plays noughts.
bool curr_move_noughts = true;

board
combined()
{
    return noughts | crosses;
}				// combined bit board for both players

bool
valid(size_t row, size_t col)
{
    return row < N && col < N;
}

size_t
pos(size_t row, size_t col)
{
    return row * N + col;
}				// map row, col to bit position

bool
occupied(size_t row, size_t col)
{
    return valid(row, col) && combined()[pos(row, col)];
}

bool
free(size_t row, size_t col)
{
    return valid(row, col) && !occupied(row, col);
}

size_t last_move_row = -1, last_move_col = -1 ;

void make_move( size_t row, size_t col, board & b )
{
    if (free(row, col))
    {
	b[pos(row, col)] = true;
        last_move_row = row ;
        last_move_col = col ;
    } 
}

void unMake(board & b )
{
	
    
    if (valid(last_move_row, last_move_col))       // if valid last_move_row, last_move_col
    {
    int row= -1;
    int col= -1;
    b[pos(row, col)] = true;
    last_move_row = -1 ;
    last_move_col = -1 ; 
    }
}

void
make_move(size_t row, size_t col)                                   
{
    if (curr_move_noughts)
	make_move(row, col, noughts);
    else
	make_move(row, col, crosses);
}

bool
is_win(board b)
{
    for (int i = 0; i < sizeof(wins) / sizeof(wins[0]); ++i) {
	if ((wins[i] & b) == wins[i])
	    return true;
    }
    return false;
}

bool
is_win()
{
    return is_win(curr_move_noughts ? noughts : crosses);
}

// is the board full?
bool is_full(board b)
{
    static board fullboard(0b111111111);
    return b == fullboard;
}

bool is_full()
{
    return is_full(curr_move_noughts ? noughts : crosses);
    
}


static int eval(board b)
{
    

    if (is_win (curr_move_noughts))
    {
        return 1;
    }
    else if (is_win (crosses))
    {
        return -1;
    }
    else
    {
        return 0;
    }
}

  


void
play()
{

    int row = -1;		// For player input
    int col = -1;

    for (int turns = 0; turns < 9; ++turns) {
	curr_move_noughts = !curr_move_noughts;

	if (curr_move_noughts) {
	  return int ComputerThink (int depth)
	} 
	 
         else {
	    cout << "Choose a move..." << endl;
	    cout << "Enter row and col : ";
	    cin >> row >> col;
	    // dmh - note that valid rows/col are 0-2, not 1-3. If you
	    // want the user to enter 1-3 then decrement the value
	    // they enter right after they enter it
	    if (!valid(row,col)) {
		cout << "Illegal move!  Try again...\n" << endl;
	    } else {
		make_move(row, col);
	    }
	}
	print_board();
	if (is_win()) {
	    cout << "Player " << (curr_move_noughts ? NOUGHT : CROSS) << " has won!" << endl; exit(0);
	} else if (is_full()) {
	    cout << "Game ended in a tie!" << endl;
	}
    }
}



ostream & print_board(ostream & stm, board b)
{
    stm << "------\n";
    for (std::size_t i = 0; i < N; ++i) {
	for (std::size_t j = 0; j < N; ++j) {
	    const size_t
		k = pos(i, j);
	    if (b[k])
		stm << (noughts[k] ? NOUGHT : CROSS) << ' ';
	    else
		stm << ". ";
	}
	stm << '\n';
    }
    return stm << "------\n";
}





int negamax( board b, unsigned int depth, side)

{

if (depth==0)

{

  int score=eval(b);
  return side * score;

}

int bestScore = -1000      
for (int x = 0; x < 9; ++x) {
 for (int y = 0; y < 9; ++y) {
while (!occupied(x,y));
make_move(b);              
int val = -negamax(b, depth -1, -side);
unMake(b);
bestScore = max(bestScore, val)
 
   }
}


return bestScore;

}



int ComputerThink (board b, unsigned int depth, int* best_pos)

{
	
int x;
int y;
int val;
int bestScore;

// Search now

for (int x = 0; x < 9; ++x) {
for (int y = 0; y < 9; ++y) {
while (!occupied(x,y));
{

val= negamax (b,2,1);

// Print the best move

make_move(x, y);
(*best_pos) = x,y;
                
   }
  }
 }

}

int
main()
{
    play();
    return 0;
}



I got nowhere with this, because

1) It doesn`t compile

2) I`m not sure if I got the logic correct

3) I`m thinking to rewrite the whole program.

What error messages do you get when you try to compile? Look at them a few at a time. Often earlier error messages induce later ones; fixing the first errors often clears up the later ones. A few points jump out at me from this last version.

I like putting a block of comments at the beginning that describe what the program is supposed to do and a general idea of how it does it.

Use consistent indentation. Each level should be indented a few spaces, say 4, in from the previous level. Not doing that can make your code hard to follow visually.

== is a comparison. = is assignment. Near the beginning, you are trying to assign a global variable side using the comparison. This should be changed to a single equals sign.

1
2
3
4
5
6
int
main()
{
    play();
    return 0;
}

Put the return type and function name on the same line.
1
2
3
4
int main(){
    play();
    return 0;
}


Also, generally avoid functions that only call another function. Just call the invoked function where you would have been calling the single-line function anyway. Of course, there are exceptions, but you should still think whether single-line functions are needed.
Last edited on
Topic archived. No new replies allowed.