This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"os" | |
) | |
// Define the flag | |
var help = flag.Bool("help", false, "Show help") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func isFlagPassed(name string) bool { | |
found := false | |
flag.Visit(func(f *flag.Flag) { | |
if f.Name == name { | |
found = true | |
} | |
}) | |
return found | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package builder; | |
public class Main { | |
public static void main(String[] args) { | |
User user1 = new User.UserBuilder("Anjana", "Shankar") | |
.build(); | |
System.out.println(user1); | |
User user2 = new User.UserBuilder("Random", "User1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package builder; | |
public class User { | |
private String firstName; | |
private String lastName; | |
private int age; | |
private String email; | |
private User(UserBuilder builder) { | |
this.firstName = builder.firstName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class User { | |
private String firstName; | |
private String lastName; | |
private int age; | |
private String email; | |
public User(String firstname, String lastname, int age, String email) { | |
this.firstname = firstname; | |
this.lastname = lastname; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"os" | |
) | |
// Define the flag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flag.Parse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flag.BoolVar(&boolFlag, "boolFlag", false, "A boolean flag") | |
flag.StringVar(&stringFlag, "stringFlag", "Hello There!", "A string flag") | |
flag.IntVar(&intFlag, "intFlag", 4, "An integer flag") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flag.Int("n", def_val, description) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var help = flag.Bool("help", false, "Show help") | |
var boolFlag = false | |
var stringFlag = "Hello There!" | |
var intFlag int |