function Union ( union : Developer | Person ) { // Union Type이 되면, 타입(Developer |or Person)의 공통된 타입만 속성이 된다. union . name ; // (property) name: string union . age ; // @Error : union.age // Why not Error?.... not or.. (property) Person.age: number !== WHY? union . skill ; // Property 'skill' does not exist on type 'Developer | Person'. // Property 'skill' does not exist on type 'Person'. } function askUnion ( union : Developer & Person ) { // Union Type이 되면, 타입(Developer &and Person)의 정의된 타입 모두 속성이 된다. union . name //(property) name: string union . age //(property) Person.age: number union . skill //(property) Developer.skill: string } var kureha : string | number | boolean // var kureha: string | number | boolean var ryosuke : string & number & boolean ; // var ryosuke: never
[C++과 언리얼로 만드는 MMORPG 게임 개발 시리즈] Part1: C++ 프로그래밍 입문
분기문 강의 28분쯤에 switch문을 어셈블리어로 확인 하는 부분이 있습니다. switch (input) 00315E8D mov eax,dword ptr [input] ---1번 00315E90 mov dword ptr [ebp-118h],eax ---2번 00315E96 cmp dword ptr [ebp-118h],0 --3번 1번 : 어셈블리어를 확인해보면 input을 eax 레지스터에 복사해 넣고 2번 : eax에 있는 값을(input 값이겠지요) 스택안에 넣는 모습[ebp-118h]을 확인할 수 있습니다. VS에서 switch 안에 있는 input을 눌러보면 switch 밖에 있는 int input = ROCK; 의 input과 동일하다는 의미로 같이 밑줄(? 그 같이 파란색으로 하이라이트)을 그어주는데 어셈블리어를 보면 switch안의 input이 아예 스택 메모리에 따로 잡히는 것 같습니다. 이건 왜 그런건가요? switch문 밖의 input과 switch(input) 안의 input은 서로 다른 input 인건가요? switch(input2)라고 하면 오류가 나던데 그렇다면 같은 input 아닌가요??? 같다면 메모리를 같이 써야 하는것 아닌지 궁금합니다.
한 게시글에서 동일한 해시태그를 여러번 사용했을 때 에러가 발생합니다 ex) #리액트 #리액트 #리액트 error -> SequelizeUniqueConstraintError: Validation error at Query.formatError 에러 로그를 보니 아래 부분이 오류라고 합니다. await post . addHashtags (result . map ((v) => v[ 0 ])); 코드에서 어떤 부분이 잘못된건가요? 그리고 추가적으로 map에서 동일한 해시태그를 입력하기 key값이 중복되어 오류가 납니다. 이러한 경우에는 key를 어떤 방식으로 넣어주는지도 궁금합니다. 아래는 routes/post.js 해시태그 부분 소스입니다. const hashtags = req . body . content . match ( /(# [ ^\s #] +)/ g ); if (hashtags) { const result = await Promise . all (hashtags . map ((v) => Hashtag . findOrCreate ({ where : { name : v . slice ( 1 ) . toLowerCase () }, }))); await post . addHashtags (result . map ((v) => v[ 0 ])); }
[C#과 유니티로 만드는 MMORPG 게임 개발 시리즈] Part1: C# 기초 프로그래밍 입문
Knight knight2 = knight.Clone(); 을 통해서 새로운객체를 만들어내는것은 이해했습니다. 다만 제가 knight2.hp =0을 안하고 디버깅을 했더니 knight2의 hp, attack 값이 기존 만들어두었던 knight의 값으로 자동으로 설정되더군요 (hp=100, attack=10) Clone 함수에서 knight.hp=hp, knight.attack=attack 이라고 지정하면 Knight클래스 내부의 변수 값을 가져오는걸로 이해했는데 public int hp, public int attack 이라고 선언만했지 초기값을 지정해주지 않았습니다. 초기값을 지정해주지 않았는데도 자동으로 값이 채워지는 이유는 무엇인가요?
안녕하세요 영한님 강의 정말 잘 듣고 있습니다! 다름이 아니라 orphanRemoval과 cascade의 명확한 차이를 공부하던 도중 이해가 가지 않는 것이 있어서 질문 드립니다! 환경은 Spring Boot 2.4.2 입니다. cascade는 엔티티의 상태변화를 전파하는 것이며, orphanRemoval는 연관관계가 끊어진 Entity는 자동으로 삭제하는 것으로 알고 있습니다. 근데 부모에서 orphanRemoval를 true로 설정 후, 컬렉션에서 자식 Entity를 삭제해도 Delete 쿼리가 아닌 update 쿼리가 발생했습니다. 그래서 여러가지 테스트 해보니 CascadeType.ALL 아니면 CascadeType.PERSIST시 orphanRemoval 이 정상적으로 동작하였습니다. 아래 코드에서 Board Entity에서 cascade 옵션을 지우면 update 쿼리가 발생하여 테스트는 실패하며, cascade 옵션을 ALL 또는 PERSIST을 사용하면 delete 쿼리가 발생하여 테스트가 정상적으로 통과합니다. 책의 p.311을 보면 orphanRemoval만 사용한 예제가 있는데 하이버네이트 버전이 올라가면서 변경된 것일까요? @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class Board { @Id @GeneratedValue private Long id; private String title; private String content; @OneToMany(mappedBy = "board", cascade = CascadeType.PERSIST, orphanRemoval = true) private List<Comment> comments = new ArrayList<>(); @Builder public Board(String title, String content) { this.title = title; this.content = content; } public Board addComment(Comment comment){ this.comments.add(comment); comment.setBoard(this); return this; } public Board removeComment(Comment comment){ this.comments.remove(comment); comment.setBoard(null); return this; } } @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class Comment { @Id @GeneratedValue private Long id; private String comment; @ManyToOne @Setter private Board board; @Builder public Comment(String comment) { this.comment = comment; } } @DataJpaTest(properties = "classpath:application-test.yml") class BoardTest { @Autowired BoardRepository boardRepository; @Autowired CommentRepository commentRepository; @DisplayName("orphanRemoval 테스트") @Test @Rollback(false) public void orphanRemovalTest(){ Board board = Board.builder().title("1번글").content("1번글 컨텐츠").build(); boardRepository.save(board); Comment comment = Comment.builder().comment("1번글 댓글").build(); board.addComment(comment); commentRepository.save(comment); entityManager.flush(); entityManager.clear(); Board board1 = boardRepository.findById(board.getId()).get(); board1.removeComment(board1.getComments().get(0)); List<Comment> commentAll = commentRepository.findAll(); assertThat(commentAll.size(), is(0)); } }
안녕하세요 궁금한거 질문입니다 혹시 쟤가 작업을 하면서 vs코드에 백엔드를 끄고 킬때마다 로그인한 상태가 계속 유지가 되는데 이게 실제 웹상에 배포를 할때 걱정이 되네여 ㅠㅜ 로그아웃을 할경우 토큰하고 토큰 시간이 없이져서 다시 기존 로그인 창이 나오기는 하지만 웹상에서 그 창을 끄거나 저기 지금 작업중에 서버를 끌때에도 아이디가 로그아웃 되게 하는 방법에 대해 참고할 만한 것이 있으면 알려주시면 감사드려요 ㅠㅜ 혹시 쟤가 코드적인 실수를 해서 그런 걸까요??
2.4.2 로 선택하고 빌드했는데 이런 이벤트 로그가 나옵니다. Plugin error: Plugin '.ignore' (version 'null') is not compatible with the current version of the IDE, because it requires build 203 or older but the current build is IC-203.6682.168 검색해봤는데도 잘 모르겠더라구요ㅠㅠ 어떻게 하면 해결할 수 있을까요ㅠㅠ?